aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/sql/types.py
diff options
context:
space:
mode:
authorDavies Liu <davies@databricks.com>2015-02-18 14:17:04 -0800
committerMichael Armbrust <michael@databricks.com>2015-02-18 14:17:04 -0800
commitaa8f10e82a743d59ce87348af19c0177eb618a66 (patch)
tree87fc8bfc978015fcf3d7ff9ff2aa3717b0885f28 /python/pyspark/sql/types.py
parentf0e3b71077a6c28aba29a7a75e901a9e0911b9f0 (diff)
downloadspark-aa8f10e82a743d59ce87348af19c0177eb618a66.tar.gz
spark-aa8f10e82a743d59ce87348af19c0177eb618a66.tar.bz2
spark-aa8f10e82a743d59ce87348af19c0177eb618a66.zip
[SPARK-5722] [SQL] [PySpark] infer int as LongType
The `int` is 64-bit on 64-bit machine (very common now), we should infer it as LongType for it in Spark SQL. Also, LongType in SQL will come back as `int`. Author: Davies Liu <davies@databricks.com> Closes #4666 from davies/long and squashes the following commits: 6bc6cc4 [Davies Liu] infer int as LongType
Diffstat (limited to 'python/pyspark/sql/types.py')
-rw-r--r--python/pyspark/sql/types.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/python/pyspark/sql/types.py b/python/pyspark/sql/types.py
index 40bd7e54a9..9409c6f9f6 100644
--- a/python/pyspark/sql/types.py
+++ b/python/pyspark/sql/types.py
@@ -583,7 +583,7 @@ def _parse_datatype_json_value(json_value):
_type_mappings = {
type(None): NullType,
bool: BooleanType,
- int: IntegerType,
+ int: LongType,
long: LongType,
float: DoubleType,
str: StringType,
@@ -933,11 +933,11 @@ def _infer_schema_type(obj, dataType):
>>> schema = _parse_schema_abstract("a b c d")
>>> row = (1, 1.0, "str", datetime.date(2014, 10, 10))
>>> _infer_schema_type(row, schema)
- StructType...IntegerType...DoubleType...StringType...DateType...
+ StructType...LongType...DoubleType...StringType...DateType...
>>> row = [[1], {"key": (1, 2.0)}]
>>> schema = _parse_schema_abstract("a[] b{c d}")
>>> _infer_schema_type(row, schema)
- StructType...a,ArrayType...b,MapType(StringType,...c,IntegerType...
+ StructType...a,ArrayType...b,MapType(StringType,...c,LongType...
"""
if dataType is None:
return _infer_type(obj)
@@ -992,7 +992,7 @@ def _verify_type(obj, dataType):
>>> _verify_type(None, StructType([]))
>>> _verify_type("", StringType())
- >>> _verify_type(0, IntegerType())
+ >>> _verify_type(0, LongType())
>>> _verify_type(range(3), ArrayType(ShortType()))
>>> _verify_type(set(), ArrayType(StringType())) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):