Skip to content

branch-4.0 [fix](match) Allow MATCH on aliased variant subcolumns#63804

Open
eldenmoon wants to merge 1 commit into
apache:branch-4.0from
eldenmoon:branch-pick-pr-63772-to-branch-4.0
Open

branch-4.0 [fix](match) Allow MATCH on aliased variant subcolumns#63804
eldenmoon wants to merge 1 commit into
apache:branch-4.0from
eldenmoon:branch-pick-pr-63772-to-branch-4.0

Conversation

@eldenmoon
Copy link
Copy Markdown
Member

@eldenmoon eldenmoon commented May 28, 2026

cherry-pick #63772

### What problem does this PR solve?

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.

### Release note

Fix MATCH predicates on VARIANT dot subcolumn access such as msg.trace_id so they are accepted like equivalent bracket subcolumn access.

### Check List (For Author)

- 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 eldenmoon changed the title [fix](fe) Allow MATCH on aliased variant subcolumns branch-4.0 [fix](match) Allow MATCH on aliased variant subcolumns May 28, 2026
@eldenmoon
Copy link
Copy Markdown
Member Author

run buildall

@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 owner May 28, 2026 07:48
Copilot AI review requested due to automatic review settings May 28, 2026 07:48
@eldenmoon eldenmoon requested a review from morningman as a code owner May 28, 2026 07:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 cherry-picks the fix to allow MATCH predicates on aliased VARIANT subcolumn accesses in the Nereids rewrite validation path.

Changes:

  • Updates CheckMatchExpression to unwrap Cast and Alias chains before validating the left operand as a SlotReference.
  • Adds unit coverage for accepted alias/cast chains and rejected non-slot alias expressions.
  • Adds an end-to-end VARIANT pruning test for cast(msg.trace_id as string) match_phrase_prefix.

Reviewed changes

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

File Description
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckMatchExpression.java Allows MATCH validation to resolve slots through cast/alias wrappers.
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/CheckMatchExpressionTest.java Adds focused tests for slot, alias, cast, and invalid expression handling.
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/VariantPruningLogicTest.java Adds integration coverage for MATCH on dot-accessed VARIANT subcolumns.

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

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 100.00% (6/6) 🎉
Increment coverage report
Complete coverage report

Sign up for free to 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.

3 participants