Skip to content

feat: support MapType input for ElementAt#4697

Open
0lai0 wants to merge 1 commit into
apache:mainfrom
0lai0:feat-4684-Support-MapType-ElementAt
Open

feat: support MapType input for ElementAt#4697
0lai0 wants to merge 1 commit into
apache:mainfrom
0lai0:feat-4684-Support-MapType-ElementAt

Conversation

@0lai0

@0lai0 0lai0 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #4684.

Rationale for this change

Comet's ElementAt serde only accepted ArrayType input. Spark supports both ArrayType and MapType, so map lookups via element_at(map, key) and try_element_at(map, key) always fell back to Spark.

What changes are included in this PR?

  • CometElementAt.getSupportLevel: accepts MapType in addition to ArrayType.
  • CometElementAt.convert: dispatches on input type, MapType routes to native map_extract (same path used by GetMapValue); ArrayType is unchanged.
  • Updates expressions.md, array_funcs.md, and map_funcs.md to reflect the new support.

How are these changes tested?

  • New SQL test file map/element_at_map.sql: covers key found, key not found (→ NULL), null map, null key, integer key type, key type coercion, and literal map arguments.
  • Updated array/try_element_at.sql: the map test case now verifies native execution rather than just comparing Spark answers.
  • Note: Spark's ElementAt for MapType does not use failOnError, key-not-found always returns NULL regardless of ANSI mode, so no ANSI fallback is needed.

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.

Support MapType for ElementAt

1 participant