@@ -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 { _ =>
0 commit comments