aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/tests.py
diff options
context:
space:
mode:
authorDavies Liu <davies@databricks.com>2014-11-24 16:41:23 -0800
committerPatrick Wendell <pwendell@gmail.com>2014-11-24 16:41:23 -0800
commit050616b408c60eae02256913ceb645912dbff62e (patch)
tree16cf868ea95f7f164fefac96be2108a65153a4d8 /python/pyspark/tests.py
parentb660de7a9cbdea3df4a37fbcf60c1c33c71782b8 (diff)
downloadspark-050616b408c60eae02256913ceb645912dbff62e.tar.gz
spark-050616b408c60eae02256913ceb645912dbff62e.tar.bz2
spark-050616b408c60eae02256913ceb645912dbff62e.zip
[SPARK-4578] fix asDict() with nested Row()
The Row object is created on the fly once the field is accessed, so we should access them by getattr() in asDict(0 Author: Davies Liu <davies@databricks.com> Closes #3434 from davies/fix_asDict and squashes the following commits: b20f1e7 [Davies Liu] fix asDict() with nested Row()
Diffstat (limited to 'python/pyspark/tests.py')
-rw-r--r--python/pyspark/tests.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/python/pyspark/tests.py b/python/pyspark/tests.py
index a01bd8d415..29bcd38908 100644
--- a/python/pyspark/tests.py
+++ b/python/pyspark/tests.py
@@ -803,7 +803,7 @@ class SQLTests(ReusedPySparkTestCase):
@classmethod
def tearDownClass(cls):
ReusedPySparkTestCase.tearDownClass()
- shutil.rmtree(cls.tempdir.name)
+ shutil.rmtree(cls.tempdir.name, ignore_errors=True)
def setUp(self):
self.sqlCtx = SQLContext(self.sc)
@@ -930,8 +930,9 @@ class SQLTests(ReusedPySparkTestCase):
rdd = self.sc.parallelize([row])
srdd = self.sqlCtx.inferSchema(rdd)
srdd.registerTempTable("test")
- row = self.sqlCtx.sql("select l[0].a AS la from test").first()
- self.assertEqual(1, row.asDict()["la"])
+ row = self.sqlCtx.sql("select l, d from test").first()
+ self.assertEqual(1, row.asDict()["l"][0].a)
+ self.assertEqual(1.0, row.asDict()['d']['key'].c)
def test_infer_schema_with_udt(self):
from pyspark.tests import ExamplePoint, ExamplePointUDT