[fix](varaint) Preserve variant sub-path order - #67803
Merged
Merged
Conversation
### What problem does this PR solve? Problem Summary: Multi-level VARIANT sub-paths are represented in canonical root-to-leaf order. Two rewrite paths rebuilt ElementAt expressions in reverse order, so a UNION ALL constant branch could read a different nested value when nested-column pruning was disabled. The change centralizes root-to-leaf ElementAt construction and uses it for UNION constant expressions and projected VARIANT expressions. Unit coverage checks the construction/extraction invariant, and regression coverage verifies UNION and project plans with nested-column pruning both disabled and enabled. ### Release note Fix incorrect values for multi-level VARIANT sub-paths in UNION ALL constant branches. ### Check List (For Author) - Test: Unit Test and Regression Test - Behavior changed: Yes. Multi-level VARIANT sub-paths now preserve SQL access order across rewritten branches. - Does this need documentation: No
morrySnow
requested review from
924060929,
englefly and
starocean999
as code owners
September 10, 2026 10:53
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 17009 ms |
Contributor
TPC-DS: Total hot run time: 82826 ms |
Contributor
ClickBench: Total hot run time: 14.75 s |
924060929
approved these changes
Sep 11, 2026
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.
What problem does this PR solve?
Problem Summary:
When nested-column pruning was disabled, a multi-level VARIANT access could return different values from the regular and constant branches of a
UNION ALL. For example, with{"a":{"b":1},"b":{"a":2}}, selectingc['a']['b']returned1from the table branch but2from the constant branch.The pruning context stores sub-paths in canonical root-to-leaf order, such as
[a, b]. The UNION constant-expression rewrite and the project pushdown rewrite rebuilt nestedElementAtexpressions by iterating those paths backwards, producingc['b']['a'].This change centralizes construction of nested
ElementAtexpressions and applies each canonical sub-path from root to leaf. It uses the same helper for UNION constant expressions and projected VARIANT expressions so extraction and reconstruction share one order contract.The regression test reproduces the UNION result mismatch with nested-column pruning disabled, covers the projected-expression path, and verifies the enabled-pruning control case.
Release note
Fix incorrect values for multi-level VARIANT sub-paths in UNION ALL constant branches.
Check List (For Author)
PruneNestedColumnTest(62 tests)variant_p0/test_variant_sub_path_order