aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/tests.py
diff options
context:
space:
mode:
authorDavies Liu <davies@databricks.com>2014-12-16 21:23:28 -0800
committerMichael Armbrust <michael@databricks.com>2014-12-16 21:23:28 -0800
commitec5c4279edabd5ea2b187aff6662ac07ed825b08 (patch)
treefdb5b450f4519b2ac88e2713128e3e8a675702a5 /python/pyspark/tests.py
parent770d8153a5fe400147cc597c8b4b703f0aa00c22 (diff)
downloadspark-ec5c4279edabd5ea2b187aff6662ac07ed825b08.tar.gz
spark-ec5c4279edabd5ea2b187aff6662ac07ed825b08.tar.bz2
spark-ec5c4279edabd5ea2b187aff6662ac07ed825b08.zip
[SPARK-4866] support StructType as key in MapType
This PR brings support of using StructType(and other hashable types) as key in MapType. Author: Davies Liu <davies@databricks.com> Closes #3714 from davies/fix_struct_in_map and squashes the following commits: 68585d7 [Davies Liu] fix primitive types in MapType 9601534 [Davies Liu] support StructType as key in MapType
Diffstat (limited to 'python/pyspark/tests.py')
-rw-r--r--python/pyspark/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/python/pyspark/tests.py b/python/pyspark/tests.py
index bca52a7ce6..b474fcf5bf 100644
--- a/python/pyspark/tests.py
+++ b/python/pyspark/tests.py
@@ -923,6 +923,14 @@ class SQLTests(ReusedPySparkTestCase):
result = self.sqlCtx.sql("SELECT l[0].a from test2 where d['key'].d = '2'")
self.assertEqual(1, result.first()[0])
+ def test_struct_in_map(self):
+ d = [Row(m={Row(i=1): Row(s="")})]
+ rdd = self.sc.parallelize(d)
+ srdd = self.sqlCtx.inferSchema(rdd)
+ k, v = srdd.first().m.items()[0]
+ self.assertEqual(1, k.i)
+ self.assertEqual("", v.s)
+
def test_convert_row_to_dict(self):
row = Row(l=[Row(a=1, b='s')], d={"key": Row(c=1.0, d="2")})
self.assertEqual(1, row.asDict()['l'][0].a)