Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spark-11158][SQL] Modified _verify_type() to be more informative on Errors by presenting the Object #9149

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/pyspark/sql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,15 +1127,15 @@ def _verify_type(obj, dataType):
return

_type = type(dataType)
assert _type in _acceptable_types, "unknown datatype: %s" % dataType
assert _type in _acceptable_types, "unknown datatype: %s for object %r" % (dataType, obj)

if _type is StructType:
if not isinstance(obj, (tuple, list)):
raise TypeError("StructType can not accept object in type %s" % type(obj))
raise TypeError("StructType can not accept object %r in type %s" % (obj, type(obj)))
else:
# subclass of them can not be fromInternald in JVM
if type(obj) not in _acceptable_types[_type]:
raise TypeError("%s can not accept object in type %s" % (dataType, type(obj)))
raise TypeError("%s can not accept object %r in type %s" % (dataType, obj, type(obj)))

if isinstance(dataType, ArrayType):
for i in obj:
Expand Down