Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit 520d92a

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 apache#17435 from szalai1/datatype-gettype-fix.
1 parent f767905 commit 520d92a

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
@@ -209,6 +209,10 @@ def test_empty_row(self):
209209
row = Row()
210210
self.assertEqual(len(row), 0)
211211

212+
def test_struct_field_type_name(self):
213+
struct_field = StructField("a", IntegerType())
214+
self.assertRaises(TypeError, struct_field.typeName)
215+
212216

213217
class SQLTests(ReusedPySparkTestCase):
214218

python/pyspark/sql/types.py

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

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

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

0 commit comments

Comments
 (0)