Skip to content

Commit 9f8d823

Browse files
committed
Fix: Return null for null entries in CometPlainVector.getBinary
1 parent 62a68ac commit 9f8d823

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

common/src/main/java/org/apache/comet/vector/CometPlainVector.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ public UTF8String getUTF8String(int rowId) {
147147

148148
@Override
149149
public byte[] getBinary(int rowId) {
150+
if (isNullAt(rowId)) {
151+
return null;
152+
}
150153
int offset;
151154
int length;
152155
if (valueVector instanceof BaseVariableWidthVector) {

spark/src/test/scala/org/apache/comet/CometArrayExpressionSuite.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,4 +777,29 @@ class CometArrayExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelp
777777
}
778778
}
779779
}
780+
781+
test("array_reverse 2") {
782+
withTempDir { dir =>
783+
val path = new Path(dir.toURI.toString, "test.parquet")
784+
val filename = path.toString
785+
val random = new Random(42)
786+
withSQLConf(CometConf.COMET_ENABLED.key -> "false") {
787+
val options = DataGenOptions(
788+
allowNull = true,
789+
generateNegativeZero = false,
790+
generateArray = true,
791+
generateStruct = false,
792+
generateMap = false)
793+
ParquetGenerator.makeParquetFile(random, spark, filename, 100, options)
794+
}
795+
withTempView("t1") {
796+
val table = spark.read.parquet(filename)
797+
table.createOrReplaceTempView("t1")
798+
for (field <- table.schema.fields.filter(_.dataType.isInstanceOf[ArrayType])) {
799+
val sql = s"SELECT ${field.name}, reverse(${field.name}) FROM t1 ORDER BY ${field.name}"
800+
checkSparkAnswer(sql)
801+
}
802+
}
803+
}
804+
}
780805
}

0 commit comments

Comments
 (0)