[X-2048] Support view matcher with boolean binary operation#27
Merged
zhuqi-lucas merged 3 commits intobranch-51from Mar 3, 2026
Merged
[X-2048] Support view matcher with boolean binary operation#27zhuqi-lucas merged 3 commits intobranch-51from
zhuqi-lucas merged 3 commits intobranch-51from
Conversation
There was a problem hiding this comment.
Pull request overview
Adds boolean predicate canonicalization to the SPJ normal form predicate collection so that semantically equivalent boolean filters (e.g., col = false and NOT col) can match during view-based rewrite, and introduces tests validating the new matching behavior.
Changes:
- Canonicalize boolean
=/!=comparisons againsttrue/falseintocol/NOT colresidual predicates. - Add rewrite tests to verify MV/query matching across
active = falseandNOT active, plusenabled = trueandenabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
xudong963
approved these changes
Mar 1, 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.
Summary
Support semantic equivalence matching for boolean binary expressions in the view matcher.
Problem
Previously, the view matcher treated
active = falseandNOT activeas different predicates, causing semantically equivalent queries and materialized views to fail to match.Solution
Normalize boolean binary expressions to a canonical form in
insert_binary_expr:col = truecolcol != falsecolcol = falseNOT colcol != trueNOT colThis ensures that predicates with equivalent semantics are stored in the same canonical form, enabling correct matching between MVs and queries.
Tests
Added 3 test cases:
test_boolean_expression_normalization: bidirectional matching betweenactive = false↔NOT activetest_boolean_column_normalization: MV withactive = falsematches query withNOT activetest_boolean_true_normalization: MV withenabled = truematches query withenabled