Skip to content

fix(plan): admit stable IN predicates for ZoneMap filtering - #32791

Open
ck89119 wants to merge 3 commits into
matrixorigin:mainfrom
ck89119:issue-21333-main
Open

ck89119 wants to merge 3 commits into
matrixorigin:mainfrom
ck89119:issue-21333-main

Conversation

@ck89119

@ck89119 ck89119 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to matrixorigin/matrixflow#21333.

What this PR does / why we need it:

Stable non-primary-column IN predicates can remain row filters without becoming block filters when statistics are unavailable or estimate no pruning benefit. Both incident CTAS queries use such a period predicate.

Admit direct-column IN with a runtime-constant List/Vec RHS through the existing simple ZoneMap filter path. Preserve main's argument validation, volatility/zonemappability checks, residual row filtering, disable hint, and statistics handling. No reader production code, CTAS transaction visibility, or execution topology changes.

This is the main-branch counterpart of #32786, adapted to main's current planner and reader contracts.

Validation performed on main with Go 1.27.1:

  • New planner regressions fail on the original implementation and pass with the fix. Focused planner/reader/ZoneMap tests and full pkg/sql/plan and pkg/vm/engine/readutil tests pass through the repository CGo wrapper.
  • Build, focused vet, and golangci-lint 2.14.0 pass. Both changed production statement blocks are covered; the admission helper has 93.8% statement coverage.
  • Generated and reviewed non_primary_zonemap results, then passed normal comparison twice: 79/79 per run, with teardown verified. Tests cover numeric/string IN, NULLs, duplicates, PREPARE reuse, CTAS, disable-hint controls, overlapping ranges, and actual scan counters.
  • Executed both complete incident CTAS queries locally using the original schema and 24 synthetic rows. Enabled/disabled controls produce identical business results and column metadata; source scans fall from 3 blocks/24 rows to 2 blocks/16 rows for each query.

These small fixtures demonstrate correctness and effective pruning, not production-scale latency improvement. Deployment and production acceptance remain pending; this PR does not claim to eliminate the reported waiting time.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

This branch is being deployed

1 in progress deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants