Repository navigation
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Design review of exact RFC head 86b6a1f62bb6e6a82fabe054c6d5c15b132ef51f: REQUEST_CHANGES before implementation.
[P1] Define session-invariant expression eligibility; the existing generated-column volatility check is insufficient
The supported-contract section at docs/rfcs/20260904_functional_indexes.md:43-55 relies on the generated-column binder and rejects volatile functions. The optimizer section at lines 102-110 then selects the index using structural expression identity plus a residual predicate. A persisted functional key requires a stronger invariant: the same base row must produce the same key during backfill, all future DML and every eligible query, regardless of session/CN evaluation settings.
A concrete counterexample under the proposed rules is an index on CAST(ts AS CHAR(19)) for a TIMESTAMP column. Current buildGeneratedColumnDef calls checkExprForVolatileFunc (pkg/sql/plan/build_util.go:767-770,843-855), which only tests CannotFold/IsRealTimeRelated. Ordinary CAST has neither flag (function/list_operator.go:2838), but timestampToOthers reads proc.GetSessionInfo().TimeZone and passes it to timestamp-to-string conversion (function/func_cast.go:2189-2222). Thus this expression is row-local and passes the cited binder's check while still being session-dependent.
Example failure path for the future implementation: backfill/write a row representing 2024-01-01 00:00:00 UTC under +00:00, storing key 2024-01-01 00:00:00; query under +08:00 with CAST(ts AS CHAR(19)) = '2024-01-01 08:00:00'. A table scan evaluates true, while the structurally identical expression-index lookup searches a key that was never stored and loses the row. The residual predicate cannot recover rows excluded by the index. Writes from sessions with different settings can also populate inconsistent keys within one index.
Please close this in the RFC rather than leaving “deterministic” undefined: specify a conservative accepted-expression rule that excludes session-dependent casts/functions (including transitive generated-column dependencies), or a persisted evaluation-context and query-eligibility contract that provably preserves SQL semantics. Merely evaluating the index in a fixed timezone is not sufficient if the query expression still uses its session timezone. Audit SQL-mode/collation-dependent evaluation under the same invariant and state how backfill, DML, restore and optimizer matching share it. Add a planned index-vs-table-scan oracle across different writer/query timezones and relevant session modes. The initial release may reject such expressions; broad support is not required.
The hidden generated-column lowering, exclusive column ownership, atomic copy-DDL direction, bounded first-release SQL surface and non-covering residual strategy are otherwise reasonable. This is a design-level counterexample based on the current reusable binder/kernel, not a claim that unimplemented functional-index SQL was executed. No production code changes are present in this PR; git diff --check passes. Resolve this semantic eligibility gap before treating the RFC as accepted, then validate the implementation separately. CI was not awaited.
|
Follow-up to XuPeng-SH's exact-head design review. Exact head: The RFC now defines a deny-by-default session-invariant eligibility contract:
Validation:
No runtime implementation or issue lifecycle change is included in this PR. Please re-review the exact head above. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Design re-review of exact head d108491c6aa6a3ecec471011c469888f73ed9fc7: approved. This is an RFC-only approval, not approval of an implementation that does not yet exist.
The previous session-dependent-key blocker is addressed at the right boundary. Eligibility is now deny-by-default and transitive through generated-column dependencies; both persisted-key evaluation and query matching must have fixed type/cast/charset/collation/error semantics. In particular, a foldable function is no longer treated as proof of session invariance, timezone-sensitive TIMESTAMP-to-text casts are rejected, and a residual predicate is explicitly not claimed to recover rows omitted by an incompatible lookup.
I reviewed the complete revised design: hidden generated-column ownership and namespace checks, atomic COPY/backfill and cleanup, DML reuse, exact-expression matching with a base-table join, restore validation, unsupported first-release cases, and cluster-capability gating. The bounded first release avoids introducing another expression evaluator and correctly leaves covering access, unique/composite indexes and wider equivalence rules out of scope. The copy rewrite, generated value and index storage costs are disclosed.
The planned validation compares index results with a forced-scan oracle across writers/query sessions, timezones, modes, DML paths and restore, and verifies rejection publishes no metadata. Those are appropriate implementation acceptance requirements rather than reasons to demand nonexistent runtime tests in this documentation PR. Implementation must reserve the then-next available MORPC capability; the historical v46 parenthetical is not an allocation to reuse.
Current head CI checks are all terminal, with successful applicable checks and skipped/neutral orchestration entries; no pending/failing check found. git diff --check passes. No production code changes or fresh native/race execution are part of this review. No confirmed design blocker remains.
Merge Queue Status
This pull request spent 15 minutes 4 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #28156 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
…8156) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28053 ## What this PR does / why we need it: This RFC defines the first functional-index contract for MatrixOne: deterministic scalar expressions lowered to owned hidden generated columns and maintained by the existing regular-index path. It records the supported and rejected SQL surface, atomic DDL and rollback ownership, catalog/SHOW/checkpoint/clone behavior, optimizer matching, mixed-version gating, and the dependency on matrixorigin#28052 and matrixorigin#28090. Validation: - Documentation-only change; `git diff --check` passes. - QA required: no for this RFC itself. The implementation PR remains QA-gated. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…8156) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28053 ## What this PR does / why we need it: This RFC defines the first functional-index contract for MatrixOne: deterministic scalar expressions lowered to owned hidden generated columns and maintained by the existing regular-index path. It records the supported and rejected SQL surface, atomic DDL and rollback ownership, catalog/SHOW/checkpoint/clone behavior, optimizer matching, mixed-version gating, and the dependency on matrixorigin#28052 and matrixorigin#28090. Validation: - Documentation-only change; `git diff --check` passes. - QA required: no for this RFC itself. The implementation PR remains QA-gated. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…8156) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28053 ## What this PR does / why we need it: This RFC defines the first functional-index contract for MatrixOne: deterministic scalar expressions lowered to owned hidden generated columns and maintained by the existing regular-index path. It records the supported and rejected SQL surface, atomic DDL and rollback ownership, catalog/SHOW/checkpoint/clone behavior, optimizer matching, mixed-version gating, and the dependency on matrixorigin#28052 and matrixorigin#28090. Validation: - Documentation-only change; `git diff --check` passes. - QA required: no for this RFC itself. The implementation PR remains QA-gated. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #28053
What this PR does / why we need it:
This RFC defines the first functional-index contract for MatrixOne: deterministic scalar expressions lowered to owned hidden generated columns and maintained by the existing regular-index path.
It records the supported and rejected SQL surface, atomic DDL and rollback ownership, catalog/SHOW/checkpoint/clone behavior, optimizer matching, mixed-version gating, and the dependency on #28052 and #28090.
Validation:
git diff --checkpasses.