Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/11492#discussion_r54978578
--- Diff: python/pyspark/sql/types.py ---
@@ -1137,7 +1148,28 @@ def _verify_type(obj, dataType):
if type(obj) not in _acceptable_types[_type]:
raise TypeError("%s can not accept object %r in type %s" %
(dataType, obj, type(obj)))
- if isinstance(dataType, ArrayType):
+ if isinstance(dataType, ByteType):
+ if obj < -128 or obj > 127:
+ raise ValueError("object of ByteType out of range, got: %s" %
obj)
+
+ elif isinstance(dataType, ShortType):
+ if obj < -32768 or obj > 32767:
+ raise ValueError("object of ShortType out of range, got: %s" %
obj)
+
+ elif isinstance(dataType, IntegerType):
+ if obj < -2147483648 or obj > 2147483647:
+ raise ValueError("object of IntegerType out of range, got: %s"
% obj)
+
+ elif isinstance(dataType, FloatType):
+ from math import isinf
+ from struct import pack, unpack
+
+ if not isinf(obj):
+ f = unpack("f", pack("f", obj))[0]
--- End diff --
I'm worried that this will be super slow, I think we don't need this.
If overflow happens, it will become infinity.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]