aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Buśkiewicz <mateusz.buskiewicz@getbase.com>2015-07-20 12:00:48 -0700
committerReynold Xin <rxin@databricks.com>2015-07-20 12:00:48 -0700
commit02181fb6d14833448fb5c501045655213d3cf340 (patch)
tree1400008a36ed564af8fd48370f38490cdcec62d6
parent80e2568b25780a7094199239da8ad6cfb6efc9f7 (diff)
downloadspark-02181fb6d14833448fb5c501045655213d3cf340.tar.gz
spark-02181fb6d14833448fb5c501045655213d3cf340.tar.bz2
spark-02181fb6d14833448fb5c501045655213d3cf340.zip
[SPARK-9101] [PySpark] Add missing NullType
JIRA: https://issues.apache.org/jira/browse/SPARK-9101 Author: Mateusz Buśkiewicz <mateusz.buskiewicz@getbase.com> Closes #7499 from sixers/spark-9101 and squashes the following commits: dd75aa6 [Mateusz Buśkiewicz] [SPARK-9101] [PySpark] Test for selecting null literal 97e3f2f [Mateusz Buśkiewicz] [SPARK-9101] [PySpark] Add missing NullType to _atomic_types in pyspark.sql.types
-rw-r--r--python/pyspark/sql/tests.py4
-rw-r--r--python/pyspark/sql/types.py2
2 files changed, 5 insertions, 1 deletions
diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py
index 86706e2dc4..7a55d801e4 100644
--- a/python/pyspark/sql/tests.py
+++ b/python/pyspark/sql/tests.py
@@ -333,6 +333,10 @@ class SQLTests(ReusedPySparkTestCase):
df = self.sqlCtx.inferSchema(rdd)
self.assertEquals(Row(field1=1, field2=u'row1'), df.first())
+ def test_select_null_literal(self):
+ df = self.sqlCtx.sql("select null as col")
+ self.assertEquals(Row(col=None), df.first())
+
def test_apply_schema(self):
from datetime import date, datetime
rdd = self.sc.parallelize([(127, -128, -32768, 32767, 2147483647, 1.0,
diff --git a/python/pyspark/sql/types.py b/python/pyspark/sql/types.py
index f75791fad1..10ad89ea14 100644
--- a/python/pyspark/sql/types.py
+++ b/python/pyspark/sql/types.py
@@ -642,7 +642,7 @@ class UserDefinedType(DataType):
_atomic_types = [StringType, BinaryType, BooleanType, DecimalType, FloatType, DoubleType,
- ByteType, ShortType, IntegerType, LongType, DateType, TimestampType]
+ ByteType, ShortType, IntegerType, LongType, DateType, TimestampType, NullType]
_all_atomic_types = dict((t.typeName(), t) for t in _atomic_types)
_all_complex_types = dict((v.typeName(), v)
for v in [ArrayType, MapType, StructType])