Skip to content

Commit 4f0833a

Browse files
committed
add python test
1 parent f515d69 commit 4f0833a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

python/pyspark/sql/tests.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,13 @@ def test_access_nested_types(self):
519519
self.assertEqual("v", df.select(df.d["k"]).first()[0])
520520
self.assertEqual("v", df.select(df.d.getItem("k")).first()[0])
521521

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+
522529
def test_infer_long_type(self):
523530
longrow = [Row(f1='a', f2=100000000000000)]
524531
df = self.sc.parallelize(longrow).toDF()

0 commit comments

Comments
 (0)