diff options
author | Elisey Zanko <elisey.zanko@gmail.com> | 2015-04-20 10:44:09 -0700 |
---|---|---|
committer | Josh Rosen <joshrosen@databricks.com> | 2015-04-20 10:44:09 -0700 |
commit | 77176619a97d07811ab20e1dde4677359d85eb33 (patch) | |
tree | 3d362532bd4a21d2c888425791418e6001485d80 /python/pyspark/sql/_types.py | |
parent | 968ad972175390bb0a96918fd3c7b318d70fa466 (diff) | |
download | spark-77176619a97d07811ab20e1dde4677359d85eb33.tar.gz spark-77176619a97d07811ab20e1dde4677359d85eb33.tar.bz2 spark-77176619a97d07811ab20e1dde4677359d85eb33.zip |
[SPARK-6661] Python type errors should print type, not object
Author: Elisey Zanko <elisey.zanko@gmail.com>
Closes #5361 from 31z4/spark-6661 and squashes the following commits:
73c5d79 [Elisey Zanko] Python type errors should print type, not object
Diffstat (limited to 'python/pyspark/sql/_types.py')
-rw-r--r-- | python/pyspark/sql/_types.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/python/pyspark/sql/_types.py b/python/pyspark/sql/_types.py index 492c0cbdcf..110d1152fb 100644 --- a/python/pyspark/sql/_types.py +++ b/python/pyspark/sql/_types.py @@ -562,8 +562,8 @@ def _infer_type(obj): else: try: return _infer_schema(obj) - except ValueError: - raise ValueError("not supported type: %s" % type(obj)) + except TypeError: + raise TypeError("not supported type: %s" % type(obj)) def _infer_schema(row): @@ -584,7 +584,7 @@ def _infer_schema(row): items = sorted(row.__dict__.items()) else: - raise ValueError("Can not infer schema for type: %s" % type(row)) + raise TypeError("Can not infer schema for type: %s" % type(row)) fields = [StructField(k, _infer_type(v), True) for k, v in items] return StructType(fields) @@ -696,7 +696,7 @@ def _merge_type(a, b): return a elif type(a) is not type(b): # TODO: type cast (such as int -> long) - raise TypeError("Can not merge type %s and %s" % (a, b)) + raise TypeError("Can not merge type %s and %s" % (type(a), type(b))) # same type if isinstance(a, StructType): @@ -773,7 +773,7 @@ def _create_converter(dataType): elif hasattr(obj, "__dict__"): # object d = obj.__dict__ else: - raise ValueError("Unexpected obj: %s" % obj) + raise TypeError("Unexpected obj type: %s" % type(obj)) if convert_fields: return tuple([conv(d.get(name)) for name, conv in zip(names, converters)]) @@ -912,7 +912,7 @@ def _infer_schema_type(obj, dataType): return StructType(fields) else: - raise ValueError("Unexpected dataType: %s" % dataType) + raise TypeError("Unexpected dataType: %s" % type(dataType)) _acceptable_types = { |