We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f515d69 commit 4f0833aCopy full SHA for 4f0833a
python/pyspark/sql/tests.py
@@ -519,6 +519,13 @@ def test_access_nested_types(self):
519
self.assertEqual("v", df.select(df.d["k"]).first()[0])
520
self.assertEqual("v", df.select(df.d.getItem("k")).first()[0])
521
522
+ def test_field_accessor(self):
523
+ df = self.sc.parallelize([Row(l=[1], r=Row(a=1, b="b"), d={"k": "v"})]).toDF()
524
+ self.assertEqual(1, df.select(df.l[0]).first()[0])
525
+ self.assertEqual(1, df.select(df.r["a"]).first()[0])
526
+ self.assertEqual("b", df.select(df.r["b"]).first()[0])
527
+ self.assertEqual("v", df.select(df.d["k"]).first()[0])
528
+
529
def test_infer_long_type(self):
530
longrow = [Row(f1='a', f2=100000000000000)]
531
df = self.sc.parallelize(longrow).toDF()
0 commit comments