Repository navigation
fix: preserve CASE NULL types and metadata - #177
Merged
osipovartem merged 1 commit intoNov 4, 2026
Merged
osipovartem merged 1 commit into
osipovartem merged 1 commit into
Conversation
Adapt apache#26951 for DF55, sharing native result type and metadata inference without redundant name/nullability work. Co-authored-by: jameswillis <[email protected]>
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?
Related to apache#24860 and the existing apache#26951 by James Willis. This adapts that fix to the Rustice DF55 runtime branch; it is not a duplicate upstream submission.
Rationale for this change
An all-false
CASEwithoutELSEbecomes a NULL literal with no field metadata. This loses extension/type annotations. It can also choose an untyped NULL from the first branch instead of the type of the complete CASE.Copying the complete CASE field fixes correctness, but our first local screen found a 24.52-31.54% planning-cost increase for unannotated column cases. That version was rejected, not merged or hidden.
What changes are included in this PR?
Case::result_type_and_metadata, sharing the existing result-type and metadata policy without computing an output name or outer-CASE nullability.to_fieldtype -> nullability -> metadata order and predicate-aware nullability logic. The metadata rules are shared rather than duplicated in the optimizer.Are these changes tested?
metadata.sltandcast_extension_type_metadata.sltpass on the final implementation.cargo +1.97.0 fmt --all --checkpasses.cargo +1.97.0 clippy --locked --offline --profile ci --all-targets --all-features -- -D warningspasses.EXPLAIN diagnostics show a typed NULL literal retaining its extension metadata after simplification. The physical plan remains a constant projection; metadata introspection folds to the correct constant extension name. The diagnostics were captured separately, not substituted for oracle expectations.
Local performance screen
Same driver, compiler, CI profile, features and dependencies; fresh expression/optimizer libraries and frozen ELFs; four interleaved AB/BA process pairs. All eight children pass their untimed checks, yielding 896 retained repetition records across 16 groups. Ratios are medians of matched process ratios, not pooled repetitions or individual-call percentiles.
No group crosses the predeclared AND gate of a matched median ratio above 1.10 and a matched median increase above 100 ns. This is not zero regression: the single-column fold costs about 0.263 us more in this CI-profile screen, adverse in all four pairs. That bounded planning cost is accepted for correct result annotations on the guarded fold; there is no new per-row execution work.
All 25 adverse pair observations, six positive-cost group summaries and the rejected first screen remain retained. The wider revised control corpus and separate campaigns do not establish a direct v1-to-v2 speedup. These are opt-level-0 planning measurements, not release/SQL/SPCS speedups, workload-frequency evidence, allocation profiling or statistical significance. Six receipt controls also pass normally and under
python -O.Are there any user-facing changes?
CASE-to-NULL simplification retains the expression's type and field metadata. The new component inference API is additive. No Snowflake comparison baseline, Rustice compatibility denominator or live-audit result was changed; Rustice dependency integration is a separate step.