[refactor](variant) refactor sub path push down on variant type (#36478) #36923
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.
pick from master #36478
intro a new rule VARIANT_SUB_PATH_PRUNING to prune variant sub path.
for example, variant slot v in table t has two sub path: 'c1' and 'c2', after this rule, select v['c1'] from t will only scan one sub path 'c1' of v to reduce scan time.
This rule accomplishes all the work using two components. The Collector traverses from the top down, collecting all the element_at functions on the variant types, and recording the required path from the original variant slot to the current element_at. The Replacer traverses from the bottom up, generating the slots for the required sub path on scan, union, and cte consumer. Then, it replaces the element_at with the corresponding slot.