Skip to content

Commit 466acaf

Browse files
committed
[SPARK-53678][SQL] Fix NPE when subclass of ColumnVector is created with null DataType
1 parent 0e42b95 commit 466acaf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

sql/catalyst/src/main/java/org/apache/spark/sql/vectorized/ColumnVector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public final VariantVal getVariant(int rowId) {
338338
* Sets up the data type of this column vector.
339339
*/
340340
protected ColumnVector(DataType type) {
341-
this.type = type.transformRecursively(
341+
this.type = type == null ? null : type.transformRecursively(
342342
new PartialFunction<DataType, DataType>() {
343343
@Override
344344
public boolean isDefinedAt(DataType x) {

sql/core/src/test/scala/org/apache/spark/sql/execution/vectorized/ConstantColumnVectorSuite.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,8 @@ class ConstantColumnVectorSuite extends SparkFunSuite {
204204
assert(vector.getChild(2).getLong(i) == 12345L)
205205
}
206206
}
207+
208+
testVector("null DataType", 0, null) { vector =>
209+
assert(vector.dataType == null)
210+
}
207211
}

0 commit comments

Comments
 (0)