Skip to content

Commit 184a883

Browse files
authored
test: fix merge conflicts in CodegenFuzzSuite and CodegenSuite (#4388)
1 parent a675092 commit 184a883

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,16 @@ class CometCodegenFuzzSuite
308308
}
309309
}
310310

311-
private def probeCardinality(accessor: String, viewName: String): Unit = {
311+
private def probeCardinality(accessor: String, dt: DataType, viewName: String): Unit = {
312+
// `Size` only supports `ArrayType` in Comet, so for `MapType` we route through `map_keys` to
313+
// reach a `Size(ArrayType)`. Spark still calls `getMap` on the column vector to extract the
314+
// keys, which is the accessor path this probe is intended to exercise.
315+
val sizeExpr = dt match {
316+
case _: MapType => s"size(map_keys($accessor))"
317+
case _ => s"cardinality($accessor)"
318+
}
312319
assertCodegenRan {
313-
checkSparkAnswerAndOperator(
314-
s"SELECT $cardinalityProbeUdf(cardinality($accessor)) FROM $viewName")
320+
checkSparkAnswerAndOperator(s"SELECT $cardinalityProbeUdf($sizeExpr) FROM $viewName")
315321
}
316322
}
317323

@@ -323,13 +329,14 @@ class CometCodegenFuzzSuite
323329
private def probeComplexColumn(field: StructField, viewName: String): Unit = {
324330
field.dataType match {
325331
case _: ArrayType | _: MapType =>
326-
probeCardinality(field.name, viewName)
332+
probeCardinality(field.name, field.dataType, viewName)
327333

328334
case st: StructType =>
329335
for (subField <- st.fields) {
330336
val accessor = s"${field.name}.${subField.name}"
331337
subField.dataType match {
332-
case _: ArrayType | _: MapType => probeCardinality(accessor, viewName)
338+
case _: ArrayType | _: MapType =>
339+
probeCardinality(accessor, subField.dataType, viewName)
333340
case dt if !isComplexType(dt) =>
334341
val udfName = s"id_${field.name}_${subField.name}"
335342
registerIdentityUdfFor(dt, udfName).foreach { _ =>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,15 @@ class CometCodegenSuite
646646
}
647647

648648
test("ScalaUDF over Decimal(38, 10) routes through the BigDecimal slow path") {
649-
spark.udf.register("decIdLong", (d: java.math.BigDecimal) => d)
649+
// Pin the return type to Decimal(38, 10). TypeTag inference for `BigDecimal` would default to
650+
// Decimal(38, 18), and under Spark 4 ANSI the encoder's CheckOverflow throws on the 28-digit
651+
// boundary value below when rescaling 10 -> 18.
652+
spark.udf.register(
653+
"decIdLong",
654+
new UDF1[java.math.BigDecimal, java.math.BigDecimal] {
655+
override def call(d: java.math.BigDecimal): java.math.BigDecimal = d
656+
},
657+
DecimalType(38, 10))
650658
withDecimalTable(
651659
"DECIMAL(38, 10)",
652660
Seq(

0 commit comments

Comments
 (0)