Repository: spark Updated Branches: refs/heads/branch-2.2 182478e03 -> b1b5a7fdc
[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 <szalaipeti.vag...@gmail.com> Closes #17435 from szalai1/datatype-gettype-fix. (cherry picked from commit 520d92a191c3148498087d751aeeddd683055622) Signed-off-by: hyukjinkwon <gurwls...@gmail.com> Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/b1b5a7fd Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/b1b5a7fd Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/b1b5a7fd Branch: refs/heads/branch-2.2 Commit: b1b5a7fdc0f8fabfb235f0b31bde0f1bfb71591a Parents: 182478e Author: Peter Szalai <szalaipeti.vag...@gmail.com> Authored: Sun Sep 10 17:47:45 2017 +0900 Committer: hyukjinkwon <gurwls...@gmail.com> Committed: Sun Sep 10 17:48:00 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/b1b5a7fd/python/pyspark/sql/tests.py ---------------------------------------------------------------------- diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py index a100dc0..39655a5 100644 --- a/python/pyspark/sql/tests.py +++ b/python/pyspark/sql/tests.py @@ -188,6 +188,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/b1b5a7fd/python/pyspark/sql/types.py ---------------------------------------------------------------------- diff --git a/python/pyspark/sql/types.py b/python/pyspark/sql/types.py index 26b54a7..d9206dd 100644 --- a/python/pyspark/sql/types.py +++ b/python/pyspark/sql/types.py @@ -438,6 +438,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: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org