Skip to content

Commit

Permalink
[SPARK-20098][PYSPARK] dataType's typeName fix
Browse files Browse the repository at this point in the history
## 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.vagyok@gmail.com>

Closes #17435 from szalai1/datatype-gettype-fix.
  • Loading branch information
szalai1 authored and HyukjinKwon committed Sep 10, 2017
1 parent f767905 commit 520d92a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/pyspark/sql/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ def test_empty_row(self):
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):

Expand Down
5 changes: 5 additions & 0 deletions python/pyspark/sql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ def toInternal(self, obj):
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`.
Expand Down

0 comments on commit 520d92a

Please sign in to comment.