Skip to content

fix: evaluate volatile IN operands once - #27448

Merged
mergify[bot] merged 20 commits into
matrixorigin:mainfrom
ck89119:issue-27088-volatile-main
Aug 22, 2026
Merged

mergify[bot] merged 20 commits into
matrixorigin:mainfrom
ck89119:issue-27088-volatile-main

Conversation

@ck89119

@ck89119 ck89119 commented Aug 21, 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:

issue #27088

What this PR does / why we need it:

Mixed-type IN and NOT IN predicates can expand one volatile left operand into multiple comparisons. This PR assigns a shared planner-local memo identity to stable volatile source nodes and evaluates each source once per root expression evaluation. Tuple operands receive independent identities per volatile element without memoizing candidate-specific cast wrappers.

It also:

  • keeps conjuncts that share one memo identity in the same expression root;
  • keeps volatile predicates out of storage reader and block-pruning evaluation so they run only at the row-level boundary;
  • prevents join predicate pushdown from moving or duplicating side-effecting predicates across join cardinality boundaries;
  • keeps volatile predicates at aggregate, sample, window, time-window, set-operation, and apply boundaries where pushdown can change evaluation cardinality or semantics;
  • keeps filters above PROJECT when column substitution would introduce a volatile projection expression;
  • includes negative memo identities in structural hashing/equality so distributivity cannot merge independent volatile occurrences.

The focused SQL regression covers prepared scalar/tuple IN and NOT IN, direct mixed-type literals, independent volatile occurrences under OR, join fan-out, one-sided join predicates over multi-row fan-out, aggregate cardinality reduction, PROJECT alias substitution, and tuple candidates with different physical cast types. It checks both query results and currval so duplicated, eliminated, prematurely evaluated, or type-confused side effects cannot pass unnoticed.

Validation:

  • focused memo executor, storage-filter, zonemap, conjunction-splitting, structural-identity, join-pushdown, cardinality-boundary, and tuple-source unit tests
  • focused embedded SQL regression (12 cases)
  • pkg/sql/colexec, pkg/sql/compile, pkg/sql/plan, and pkg/tests/issues test suites
  • owning-package build and vet
  • focused regressions reproduced with the expected semantic failures before their fixes

@XuPeng-SH XuPeng-SH 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.

Re-reviewed exact HEAD b358960.

The previous P1 is closed: volatile predicates now stay above AGG and the other audited cardinality-changing boundaries, and volatile project substitutions are kept above PROJECT. The original result-plus-currval reproduction now returns the expected count = 0 and currval = 1.

I also ran the focused planner/colexec/compile tests, the embedded volatile-IN regression with additional flattened-subquery and forced-index counterexamples, and the memo executor test under -race (count=10); all passed. CI is green. No blocking findings.

@mergify mergify Bot added the queued label Aug 22, 2026
@mergify

mergify Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-22 18:38 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-08-22 19:43 UTC · at fe8d74ca3795d6db8851bee3215177a5ce0fb561 · squash

This pull request spent 1 hour 4 minutes 45 seconds in the queue, including 1 hour 4 minutes 23 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)

This branch was previously deployed

1 inactive 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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants