Skip to content

fix: prevent native sort crash for Struct(Map(...)) keys#4157

Open
0lai0 wants to merge 1 commit intoapache:mainfrom
0lai0:feat-4123-Struct/Map
Open

fix: prevent native sort crash for Struct(Map(...)) keys#4157
0lai0 wants to merge 1 commit intoapache:mainfrom
0lai0:feat-4123-Struct/Map

Conversation

@0lai0
Copy link
Copy Markdown
Contributor

@0lai0 0lai0 commented Apr 30, 2026

Which issue does this PR close?

Closes #4123

Rationale for this change

Spark 4.1.1 SQL coverage exposed a case where Comet allows native aggregation for grouping keys that contain nested MapType (for example StructType(MapType(...))).
Although planning succeeds, downstream native sort/row-format handling does not support this shape, so the query fails at execution time instead of falling back to Spark during planning.

This PR makes aggregate planning reject map-containing grouping key types so these queries reliably fall back to Spark.

What changes are included in this PR?

  • add a recursive containsMapType helper in CometBaseAggregate
  • make aggregate planning fall back when any grouping expression contains MapType directly or nested in StructType/ArrayType
  • add regression test in CometAggregateSuite for grouping on Struct(Map(...))
  • add regression test in CometAggregateSuite for grouping on Array(Map(...))

How are these changes tested?

  • ./mvnw test -Pspark-4.1 -Dtest=none -Dsuites="org.apache.comet.exec.CometAggregateSuite grouping on struct containing map should fallback to Spark"
  • ./mvnw test -Pspark-4.1 -Dtest=none -Dsuites="org.apache.comet.exec.CometAggregateSuite group by array of map falls back to Spark (issue #4123)"
  • ./mvnw test -Pspark-4.1 -Dtest=none -Dsuites="org.apache.comet.exec.CometAggregateSuite"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comet native sort lacks row-format support for Struct(Map(...)) sort keys

1 participant