Skip to content

Commit b1b5a7f

Browse files
szalai1HyukjinKwon
authored andcommitted
[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. (cherry picked from commit 520d92a) Signed-off-by: hyukjinkwon <[email protected]>
1 parent 182478e commit b1b5a7f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

python/pyspark/sql/tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ def test_empty_row(self):
188188
row = Row()
189189
self.assertEqual(len(row), 0)
190190

191+
def test_struct_field_type_name(self):
192+
struct_field = StructField("a", IntegerType())
193+
self.assertRaises(TypeError, struct_field.typeName)
194+
191195

192196
class SQLTests(ReusedPySparkTestCase):
193197

python/pyspark/sql/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,11 @@ def toInternal(self, obj):
438438
def fromInternal(self, obj):
439439
return self.dataType.fromInternal(obj)
440440

441+
def typeName(self):
442+
raise TypeError(
443+
"StructField does not have typeName. "
444+
"Use typeName on its type explicitly instead.")
445+
441446

442447
class StructType(DataType):
443448
"""Struct type, consisting of a list of :class:`StructField`.

0 commit comments

Comments
 (0)