Skip to content

feat: support MapType input for ElementAt - #4697

Merged
comphead merged 2 commits into
apache:mainfrom
0lai0:feat-4684-Support-MapType-ElementAt
Jun 22, 2026
Merged

comphead merged 2 commits 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.

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @0lai0

@comphead
comphead merged commit 3ea5fb0 into apache:main Jun 22, 2026
69 checks passed
marvelshan pushed a commit to marvelshan/datafusion-comet that referenced this pull request Jul 2, 2026
* feat: support MapType input for ElementAt

* Update docs/source/user-guide/latest/expressions.md

---------

Co-authored-by: Oleks V <comphead@users.noreply.github.com>
comphead added a commit to comphead/arrow-datafusion-comet that referenced this pull request Aug 26, 2026
* feat: support MapType input for ElementAt

* Update docs/source/user-guide/latest/expressions.md

---------

Co-authored-by: Oleks V <comphead@users.noreply.github.com>
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

2 participants