Add nested struct schema evolution support for Map types#23914
Open
kosiew wants to merge 10 commits into
Open
Conversation
- Adapt recursive Map key/value structures. - Implement shared planner/runtime validation. - Preserve offsets and nulls; require matching sorted flags. - Enforce Arrow Map entry/key invariants. - Handle nullable additions, extras, null/all-null maps, and incompatible/non-nullable rejections. - Add Parquet end-to-end regression tests.
…etadata internally - Updated cast_map_column to accept &MapArray and reduce redundant arguments - Extracted a shared error assertion helper for planner/runtime components
- Map key/value children now matched positionally while preserving target technical names. - Implemented safe key evolution with no source key-field removal, injective primitive widening, nullable additions, and unchanged key types for sorted Maps. - Compacted hidden null-parents and sliced unreachable entries before casting. - Updated public rustdoc to document Map evolution semantics. - Expanded Parquet test coverage for differing physical/logical entry names. - Added planner/runtime regressions tests for uniqueness, sortedness, nulls, slices, and unsafe casts.
- Allow sorted targets to be set to false. - Reject transitioning from sorted=false to sorted=true. - Maintain requirement for unchanged key types in sorted targets. - Allow downgraded unsorted targets to utilize existing safe key evolution. - Update public Rust documentation. - Add planner/runtime parity and value/key assertions.
- Reused validated target Map children and eliminated duplicate validation and map_entry_fields. - Implemented common planner/runtime error assertion helper. - Removed redundant sortedness assertions that are already covered by exact type equality. - Public APIs remain unchanged.
…structs at planner boundary - Added regression test for empty key struct to ensure nullable-only target key field is rejected in both planner and runtime.
…chema helpers - Added `test_map_value_struct_incompatible_schema_evolution_rejected` for end-to-end negative testing of Parquet. - Refactored shared map fixture and schema helper functions for improved clarity and reusability.
- Removed unused `let _ =` in nested_struct.rs - Added local name lookup/set for map key struct validation in nested_struct.rs - Extracted shared map E2E setup helper in expr_adapter.rs - Added nullable/non-nullable schema wrapper helpers, avoiding bool at call sites in expr_adapter.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23914 +/- ##
==========================================
+ Coverage 80.65% 80.69% +0.03%
==========================================
Files 1091 1094 +3
Lines 371031 372366 +1335
Branches 371031 372366 +1335
==========================================
+ Hits 299256 300478 +1222
- Misses 53935 53981 +46
- Partials 17840 17907 +67 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Updated the sorted to unsorted test to enforce rejection. - Clarified documentation for requires_nested_struct_cast Map behavior. - Extracted compact_map_entries() with explanation for identity take. - Extracted is_injective_map_key_cast() and added documentation for conservative policy.
… cast_map_column and rewording to “specialized Map casting path”
kosiew
marked this pull request as ready for review
July 27, 2026 05:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #20835
This is the last of a series of PR to close #20835
Rationale for this change
Maptypes were not handled by DataFusion's recursive nested schema adaptation logic, leaving map key/value struct evolution undefined and unsupported. This change adds centralized validation and casting semantics forMapcolumns so planner-time validation and runtime casting behave consistently for supported schema evolution scenarios while rejecting unsafe key evolution.What changes are included in this PR?
Add recursive
Mapsupport to the nested schema adaptation path used by planning and execution.Introduce
Mapcompatibility validation covering:Structfields,Implement
Mapcasting that:Extend nested-cast detection so compatible
Maptypes are routed through the specialized nested adaptation path.Document supported map evolution semantics alongside the validation logic.
Add comprehensive unit tests covering:
Add end-to-end Parquet tests covering successful map value struct evolution and rejection of incompatible evolution.
Are these changes tested?
Yes.
New test coverage includes unit tests in
nested_struct.rsfor:It also adds end-to-end Parquet tests:
test_map_value_struct_schema_evolution_end_to_endtest_map_value_struct_incompatible_schema_evolution_rejectedAre there any user-facing changes?
Yes.
DataFusion now supports recursive schema adaptation for compatible
Maptypes whose keys and/or values recursively containStructs. Compatible schema evolution is applied during planning and execution using consistent validation rules, while unsupported or unsafe map key evolution, sorted-flag changes, and incompatible non-nullable schema changes are rejected. This extends schema evolution behavior but does not introduce a public API change.LLM-generated code disclosure
This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed.