File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed
main/scala/org/apache/spark/sql/catalyst
test/scala/org/apache/spark/sql/catalyst/encoders Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ object RowEncoder {
48
48
private def extractorsFor (
49
49
inputObject : Expression ,
50
50
inputType : DataType ): Expression = inputType match {
51
- case BooleanType | ByteType | ShortType | IntegerType | LongType |
51
+ case NullType | BooleanType | ByteType | ShortType | IntegerType | LongType |
52
52
FloatType | DoubleType | BinaryType => inputObject
53
53
54
54
case udt : UserDefinedType [_] =>
@@ -143,6 +143,7 @@ object RowEncoder {
143
143
case _ : MapType => ObjectType (classOf [scala.collection.Map [_, _]])
144
144
case _ : StructType => ObjectType (classOf [Row ])
145
145
case udt : UserDefinedType [_] => ObjectType (udt.userClass)
146
+ case _ : NullType => ObjectType (classOf [java.lang.Object ])
146
147
}
147
148
148
149
private def constructorFor (schema : StructType ): Expression = {
@@ -158,7 +159,7 @@ object RowEncoder {
158
159
}
159
160
160
161
private def constructorFor (input : Expression ): Expression = input.dataType match {
161
- case BooleanType | ByteType | ShortType | IntegerType | LongType |
162
+ case NullType | BooleanType | ByteType | ShortType | IntegerType | LongType |
162
163
FloatType | DoubleType | BinaryType => input
163
164
164
165
case udt : UserDefinedType [_] =>
Original file line number Diff line number Diff line change @@ -369,6 +369,9 @@ case class MapObjects(
369
369
private lazy val completeFunction = function(loopAttribute)
370
370
371
371
private def itemAccessorMethod (dataType : DataType ): String => String = dataType match {
372
+ case NullType =>
373
+ val nullTypeClassName = NullType .getClass.getName + " .MODULE$"
374
+ (i : String ) => s " .get( $i, $nullTypeClassName) "
372
375
case IntegerType => (i : String ) => s " .getInt( $i) "
373
376
case LongType => (i : String ) => s " .getLong( $i) "
374
377
case FloatType => (i : String ) => s " .getFloat( $i) "
Original file line number Diff line number Diff line change @@ -80,11 +80,13 @@ class RowEncoderSuite extends SparkFunSuite {
80
80
private val structOfString = new StructType ().add(" str" , StringType )
81
81
private val structOfUDT = new StructType ().add(" udt" , new ExamplePointUDT , false )
82
82
private val arrayOfString = ArrayType (StringType )
83
+ private val arrayOfNull = ArrayType (NullType )
83
84
private val mapOfString = MapType (StringType , StringType )
84
85
private val arrayOfUDT = ArrayType (new ExamplePointUDT , false )
85
86
86
87
encodeDecodeTest(
87
88
new StructType ()
89
+ .add(" null" , NullType )
88
90
.add(" boolean" , BooleanType )
89
91
.add(" byte" , ByteType )
90
92
.add(" short" , ShortType )
@@ -101,6 +103,7 @@ class RowEncoderSuite extends SparkFunSuite {
101
103
102
104
encodeDecodeTest(
103
105
new StructType ()
106
+ .add(" arrayOfNull" , arrayOfNull)
104
107
.add(" arrayOfString" , arrayOfString)
105
108
.add(" arrayOfArrayOfString" , ArrayType (arrayOfString))
106
109
.add(" arrayOfArrayOfInt" , ArrayType (ArrayType (IntegerType )))
You can’t perform that action at this time.
0 commit comments