Skip to content

Commit 6bf11f0

Browse files
committed
add test
1 parent 0a18192 commit 6bf11f0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
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()
193+
self.assertRaises(typeError('StructField does not have typename. You can use self.dataType.simpleString() instead.'), struct_field.typeName)
194+
191195

192196
class SQLTests(ReusedPySparkTestCase):
193197

python/pyspark/sql/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def fromInternal(self, obj):
439439
return self.dataType.fromInternal(obj)
440440

441441
def typeName(self):
442-
raise TypeError('StructField does not have typename')
442+
raise TypeError('StructField does not have typename. You can use self.dataType.simpleString() instead.')
443443

444444

445445
class StructType(DataType):

0 commit comments

Comments
 (0)