Repository: spark Updated Branches: refs/heads/master f76790557 -> 520d92a19
[SPARK-20098][PYSPARK] dataType's typeName fix ## What changes were proposed in this pull request? `typeName` classmethod has been fixed by using type -> typeName map. ## How was this patch tested? local build Author: Peter Szalai <[email protected]> Closes #17435 from szalai1/datatype-gettype-fix. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/520d92a1 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/520d92a1 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/520d92a1 Branch: refs/heads/master Commit: 520d92a191c3148498087d751aeeddd683055622 Parents: f767905 Author: Peter Szalai <[email protected]> Authored: Sun Sep 10 17:47:45 2017 +0900 Committer: hyukjinkwon <[email protected]> Committed: Sun Sep 10 17:47:45 2017 +0900 ---------------------------------------------------------------------- python/pyspark/sql/tests.py | 4 ++++ python/pyspark/sql/types.py | 5 +++++ 2 files changed, 9 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/520d92a1/python/pyspark/sql/tests.py ---------------------------------------------------------------------- diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py index 4d65abc..6e7ddf9 100644 --- a/python/pyspark/sql/tests.py +++ b/python/pyspark/sql/tests.py @@ -209,6 +209,10 @@ class DataTypeTests(unittest.TestCase): row = Row() self.assertEqual(len(row), 0) + def test_struct_field_type_name(self): + struct_field = StructField("a", IntegerType()) + self.assertRaises(TypeError, struct_field.typeName) + class SQLTests(ReusedPySparkTestCase): http://git-wip-us.apache.org/repos/asf/spark/blob/520d92a1/python/pyspark/sql/types.py ---------------------------------------------------------------------- diff --git a/python/pyspark/sql/types.py b/python/pyspark/sql/types.py index 51bf7be..920cf00 100644 --- a/python/pyspark/sql/types.py +++ b/python/pyspark/sql/types.py @@ -440,6 +440,11 @@ class StructField(DataType): def fromInternal(self, obj): return self.dataType.fromInternal(obj) + def typeName(self): + raise TypeError( + "StructField does not have typeName. " + "Use typeName on its type explicitly instead.") + class StructType(DataType): """Struct type, consisting of a list of :class:`StructField`. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
