Skip to content

fix: derive custom nullability for spark map_from_entries - #19274

Merged
comphead merged 1 commit into
apache:mainfrom
kumarUjjawal:fix/map_front_entries_nullable
Dec 12, 2025
Merged

comphead merged 1 commit into
apache:mainfrom
kumarUjjawal:fix/map_front_entries_nullable

Conversation

@kumarUjjawal

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

  • Spark map_from_entries now uses return_field_from_args to handle nullability

Are these changes tested?

  • Added new unit tests to cover the changes
  • Previous tests pass

Are there any user-facing changes?

@github-actions github-actions Bot added the spark Changes to datafusion-spark crate label Dec 11, 2025

@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 @kumarUjjawal

@comphead
comphead added this pull request to the merge queue Dec 12, 2025
Merged via the queue into apache:main with commit 18e4a0c Dec 12, 2025
27 checks passed
kszucs pushed a commit to kszucs/datafusion that referenced this pull request Jun 1, 2026
## Which issue does this PR close?

Closes # (none: prerequisite for
apache/datafusion-comet#2706; follow-up to
apache#17779 and apache#19274).

## Rationale for this change

Spark's default mapKeyDedupPolicy is EXCEPTION, raising
SparkRuntimeException with error class DUPLICATED_MAP_KEY on duplicate
map keys. The existing Spark map_from_entries / map_from_arrays UDFs
silently kept the last occurrence, forcing downstream engines like
datafusion-comet to fall back to Spark.

## What changes are included in this PR?

Duplicate map keys in Spark map_from_entries, map_from_arrays, and
str_to_map now raise [DUPLICATED_MAP_KEY] Duplicate map key {key} was
found, matching Spark's default behaviour and error class.

## Are these changes tested?

Yes, via sqllogictest assertions covering the new error across the
affected Spark map UDFs.

## Are there any user-facing changes?

Yes. Duplicate keys now raise [DUPLICATED_MAP_KEY] under the default
policy instead of silently collapsing to the last occurrence. No new
config keys, no API changes.

---------

Co-authored-by: Krishna Sudarshan J <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spark Changes to datafusion-spark crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spark map_from_entries need to have custom nullability

2 participants