Skip to content

branch-4.1 [fix](match) Allow MATCH on aliased variant subcolumns - #63811

Merged
yiguolei merged 1 commit into
apache:branch-4.1from
eldenmoon:branch-pick-pr-63772-to-branch-4.1
May 29, 2026
Merged

branch-4.1 [fix](match) Allow MATCH on aliased variant subcolumns#63811
yiguolei merged 1 commit into
apache:branch-4.1from
eldenmoon:branch-pick-pr-63772-to-branch-4.1

Conversation

@eldenmoon

@eldenmooneldenmoon commented May 28, 2026

Copy link
Copy Markdown
Member

cherry-pick #63772

Issue Number: None
Related PR: apache#63772
Problem Summary: MATCH predicates fail for VARIANT dot subcolumn access such as cast(msg.trace_id as string), while the equivalent bracket access msg['trace_id'] works. Dot access can leave an Alias around the pruned subcolumn slot, and CheckMatchExpression rejected the aliased slot.
Fix MATCH predicates on VARIANT dot subcolumn access such as msg.trace_id so they are accepted like equivalent bracket subcolumn access.
- Test:
- Unit Test: ./run-fe-ut.sh --run org.apache.doris.nereids.rules.rewrite.CheckMatchExpressionTest
- Unit Test: ./run-fe-ut.sh --run org.apache.doris.nereids.rules.rewrite.VariantPruningLogicTest#testMatchOnDotVariantSubColumnUsesSlotRefInScanPredicate
- Behavior changed: Yes. MATCH validation now accepts alias/cast chains that resolve to a SlotReference, while still rejecting aliases over non-slot expressions.
- Does this need documentation: No
(cherry picked from commit d0cfb94)
(cherry picked from commit 26abcfcdb9a04a3d7244ccad5d17c7bdd7a1dfa9)
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@eldenmoon

Copy link
Copy Markdown
MemberAuthor

run buildall

@eldenmooneldenmoon changed the title [fix](fe) Allow MATCH on aliased variant subcolumns[fix](match) Allow MATCH on aliased variant subcolumnsMay 28, 2026
@eldenmooneldenmoon changed the title [fix](match) Allow MATCH on aliased variant subcolumnsbranch-4.1 [fix](match) Allow MATCH on aliased variant subcolumnsMay 28, 2026
@eldenmoon
eldenmoon marked this pull request as ready for review May 28, 2026 07:48
@eldenmoon
eldenmoon requested a review from yiguolei as a code ownerMay 28, 2026 07:48
CopilotAI review requested due to automatic review settings May 28, 2026 07:48

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes MATCH predicate validation for VARIANT dot-access subcolumns (e.g., v.trace_id) when pruning/rewrites introduce Alias (and Cast) wrappers around the underlying SlotReference, making dot access behave like equivalent bracket access (e.g., v['trace_id']).

Changes:

  • Extend MATCH validation to unwrap Alias in addition to Cast when resolving the left operand down to a SlotReference.
  • Add unit tests ensuring alias/cast chains over VARIANT subcolumn slots are accepted, while aliases over non-slot expressions are still rejected.
  • Add an integration-style planner test verifying the scan predicate uses a SlotRef with the expected VARIANT subcolumn labels for dot access.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

FileDescription
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckMatchExpression.javaAllow MATCH left operand resolution through Alias + Cast chains to reach the underlying SlotReference.
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/CheckMatchExpressionTest.javaAdd test coverage for alias/cast chains on VARIANT subcolumn MATCH and rejection for alias-on-expression.
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/VariantPruningLogicTest.javaVerify planned scan conjunct contains a MatchPredicate whose left child resolves to a SlotRef with trace_id subcolumn labels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 9.09% (1/11) 🎉
Increment coverage report
Complete coverage report

@yiguolei
yiguolei merged commit d959ea0 into apache:branch-4.1May 29, 2026
35 of 38 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@eldenmoon@hello-stephen@yiguolei