Repository navigation
[branch-56] fix: infer UNION output types before analysis (backport #27139) - #27178
Merged
Merged
Conversation
## Which issue does this PR close? - Closes apache#27023. - Part of apache#14380. UNION inputs still need analyzer casts. ## Rationale for this change `DataFrame::schema()` previously reported the first UNION input's type while execution used the common type. UNION construction now infers the common output type. ## What changes are included in this PR? - Infer UNION and CASE result types before analysis, with cast insertion deferred to the analyzer. - Derive final UNION types from actual inputs with the shared `coerce_union_type` helper. - A branch-56 backport remains a maintainer decision because public inference behavior and one executed Arrow type change. Synthetic nested CASE planning (`ci-bench`, SQL through physical planning): | Depth | Main (µs) | Patch (µs) | Extra (µs) | | --- | --- | --- | --- | | 8 | 101.2 | 105.5 | +4.3 | | 32 | 270.1 | 317.6 | +47.5 | | 64 | 502.8 | 684.0 | +181.2 | These three points suggest roughly quadratic extra work. Extrapolating that trend to depth 1,000 gives about 45 ms of extra planning. The benchmark did not measure depth 1,000. ## What is the testing strategy for this PR? Focused core and expression tests (316), 64 doctests, five SLT files, all-features Clippy, Rustdoc, and formatting pass. ## Are there any user-facing changes? In this query, `x` changes from `Dictionary(Int32, Utf8)` to `Utf8`; decoded values remain unchanged. Rustdoc describes UNION and CASE schema inference. ```sql SELECT 1 AS y UNION ALL BY NAME SELECT arrow_cast('a', 'Dictionary(Int32, Utf8)') AS x; ``` (cherry picked from commit 13bd9d1)
28 of 54 tasks
mbutrovich
approved these changes
Nov 6, 2026
mbutrovich
left a comment
Contributor
There was a problem hiding this comment.
Looks like a clean cherry-pick, approved pending CI. Thanks @alamb!
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## branch-56 #27178 +/- ##
==========================================
Coverage 83.26% 83.26%
==========================================
Files 1169 1169
Lines 474209 474299 +90
Branches 474209 474299 +90
==========================================
+ Hits 394853 394935 +82
- Misses 55458 55459 +1
- Partials 23898 23905 +7
... and 5 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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?
branch-5656.0.0(Oct/Nov 2026) #24461