[fix](nereids) Preserve column metadata in Alias.toSlot() for wrapped expressions#60839
Open
airborne12 wants to merge 1 commit intoapache:masterfrom
Open
[fix](nereids) Preserve column metadata in Alias.toSlot() for wrapped expressions#60839airborne12 wants to merge 1 commit intoapache:masterfrom
airborne12 wants to merge 1 commit intoapache:masterfrom
Conversation
… expressions When Alias wraps non-SlotReference expressions like Cast(ElementAt(SlotRef, Literal)) (variant subcolumn access), toSlot() was losing originalTable, originalColumn, oneLevelTable, oneLevelColumn, and subPath metadata. This caused ExpressionTranslator.visitMatch() to crash with "SlotReference in Match failed to get Column" when MATCH was inside OR predicates (where pushdown through project doesn't happen). Fix: Use getInputSlots() to find the unique underlying SlotReference through any expression wrapper depth. Also fixed pre-existing bug where oneLevelColumn parameter was incorrectly using getOriginalColumn() instead of getOneLevelColumn().
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Member
Author
|
run buildall |
TPC-H: Total hot run time: 28777 ms |
TPC-DS: Total hot run time: 183883 ms |
morrySnow
requested changes
Feb 26, 2026
| * unambiguous column origin. Handles Cast(slot), Cast(ElementAt(slot, literal)), etc. | ||
| * Returns null for multi-slot expressions like CONCAT(col1, col2). | ||
| */ | ||
| private static SlotReference extractSlotReference(Expression expr) { |
Contributor
There was a problem hiding this comment.
You cannot search for SlotReference in the child nodes in this way. Because the original purpose of the name-related fields in Slot was to be compatible with the metadata in the MySQL protocol. This approach of searching will violate the constraints of the MySQL protocol.
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?
Issue Number: close #xxx
Problem Summary:
When
Alias.toSlot()wraps a non-SlotReference expression (e.g.,Cast(ElementAt(SlotRef, Literal))for variant subcolumn access, orCast(SlotRef)for explicit type conversion), it loses column metadata (originalTable,originalColumn,oneLevelTable,oneLevelColumn,subPath).This causes
ExpressionTranslator.visitMatch()to crash with:The bug manifests when MATCH is inside an OR predicate, because:
Fix: Added
extractSlotReference()that usesgetInputSlots()to find the unique underlyingSlotReferencethrough any expression wrapper depth (Cast, ElementAt, etc.). Only returns a SlotReference when there is exactly one input slot, ensuring unambiguous column origin. Returns null for multi-slot expressions likeCONCAT(col1, col2).Also fixed a pre-existing bug where the
oneLevelColumnparameter was incorrectly passinggetOriginalColumn()instead ofgetOneLevelColumn().Release note
Fix MATCH expressions crashing with "SlotReference in Match failed to get Column" when used on alias columns (from CTE/subquery) combined with OR predicates.
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)