Skip to content

Commit f1fb980

Browse files
authored
fix: Byte array Literals failed on cast (apache#2432)
1 parent 3778f34 commit f1fb980

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

spark/src/main/scala/org/apache/comet/serde/literals.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ object CometLiteral extends CometExpressionSerde[Literal] with Logging {
131131
})
132132
case ByteType =>
133133
array.foreach(v => {
134-
val casted = v.asInstanceOf[Integer]
135-
listLiteralBuilder.addByteValues(casted)
134+
val casted = v.asInstanceOf[lang.Byte]
135+
listLiteralBuilder.addByteValues(casted.intValue())
136136
listLiteralBuilder.addNullMask(casted != null)
137137
})
138138
case ShortType =>

spark/src/test/scala/org/apache/comet/exec/CometNativeReaderSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ class CometNativeReaderSuite extends CometTestBase with AdaptiveSparkPlanHelper
468468
"""
469469
|select 1 a
470470
|""".stripMargin,
471-
"select array(1, 2, null, 3, null) from tbl")
471+
"select array(cast(1 as byte), cast(2 as byte), null, cast(3 as byte), null) from tbl")
472472
}
473473

474474
test("native reader - support ARRAY literal SHORT fields") {

0 commit comments

Comments
 (0)