Skip to content

[X-2048] Support view matcher with boolean binary operation#27

Merged
zhuqi-lucas merged 3 commits intobranch-51from
branch-51-boolean-match
Mar 3, 2026
Merged

[X-2048] Support view matcher with boolean binary operation#27
zhuqi-lucas merged 3 commits intobranch-51from
branch-51-boolean-match

Conversation

@zhuqi-lucas
Copy link
Collaborator

@zhuqi-lucas zhuqi-lucas commented Feb 25, 2026

Summary

Support semantic equivalence matching for boolean binary expressions in the view matcher.

Problem

Previously, the view matcher treated active = false and NOT active as 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:

Expression Normalized Form
col = true col
col != false col
col = false NOT col
col != true NOT col

This 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 between active = falseNOT active
  • test_boolean_column_normalization: MV with active = false matches query with NOT active
  • test_boolean_true_normalization: MV with enabled = true matches query with enabled

Copilot AI review requested due to automatic review settings February 25, 2026 08:21
Copy link

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

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 against true/false into col / NOT col residual predicates.
  • Add rewrite tests to verify MV/query matching across active = false and NOT active, plus enabled = true and enabled.

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

@zhuqi-lucas zhuqi-lucas merged commit 6d0e950 into branch-51 Mar 3, 2026
8 checks passed
@zhuqi-lucas zhuqi-lucas deleted the branch-51-boolean-match branch March 3, 2026 09:12
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