Repository navigation
fix(plan): let EXPLAIN format sequence functions in group keys - #30386
Conversation
The four sequence functions (NEXTVAL/SETVAL/CURRVAL/LASTVAL) register with the UNKNOW_KIND_FUNCTION layout, and funcExprExplain rejected that layout outright. EXPLAIN therefore failed with 'explain contains UNKNOW_KIND_FUNCTION' whenever a sequence function surfaced as a DISTINCT or GROUP BY aggregate group key, while the query itself executed correctly. Format them as ordinary name(args) calls instead (fixes matrixorigin#30366).
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? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 419c1963f464b577fd56f67eb246912742b8e993
Assessment: approve
Reviewed the complete two-file delta and affected callers. The fix belongs in the existing EXPLAIN formatter, reuses recursive argument rendering and error propagation, and removes the incorrect rejection without evaluating sequence functions. No actionable correctness, design, compatibility, or performance issue remains.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
Validation:
-
Full EXPLAIN package passed with additive reviewer tests: all eight sequence overloads, nesting, complete output, JSON labels, error propagation, and ten DISTINCT/GROUP BY planner cases.
-
All ten planner reproductions failed with the exact base formatter's original error, confirming regression sensitivity.
-
Embedded frontend validation passed 36 text/JSON EXPLAIN calls across two rounds on one instance, including view-bound calls, unchanged sequence state, execution controls, and verified cleanup. An initial reviewer assertion about view projection display was corrected; both logs are retained.
-
Preflight passed; native inputs and artifacts were hash-verified through the repository build workflow. Source remained unchanged. Commands, source fingerprints, exit receipts, and logs were reconciled in /home/xupeng/.local/state/mo-bot/jobs/092b8235e3366ae05b993ae3/attempt-1/review-evidence.json.
Limitations:
-
Issue #30366's standalone body and raw CI logs were absent; its behavioral contract was evaluated from the frozen PR description and independently reproduced.
-
Public validation used an embedded single-CN frontend. No performance benchmark was run: added work is proportional to rendered sequence arguments, with no changes to per-row execution.
Merge Queue Status
This pull request spent 9 minutes 6 seconds in the queue, with no time running CI. ReasonPull request #30386 has been merged manually at 14a8d85 HintYou were too fast! Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
fixes #30366
What this PR does / why we need it:
EXPLAINrejected valid queries when a sequence function appeared as aDISTINCTorGROUP BYkey, failing withinvalid input: explain contains UNKNOW_KIND_FUNCTION, while the queries themselves executed correctly.Root cause: the four sequence functions (
nextval,setval,currval,lastval) register with theUNKNOW_KIND_FUNCTIONexplain layout, andfuncExprExplainreturned an error unconditionally for that layout. A plain projection never prints the call the same way, butDISTINCT/GROUP BYexposes it as an aggregate group key that the explain formatter visits, hitting the error branch.Fix: format
UNKNOW_KIND_FUNCTIONcalls as ordinaryname(args...)text instead of failing. No evaluation or sequence-state change is involved — EXPLAIN only renders the plan.Tests: new
TestExplainSequenceFunctionAsGroupKeycovers all four sequence functions through the real registered overloads (function.GetFunctionByName), assertingdescribeExprsucceeds and emitsnextval(/currval(/setval(/lastval. Fullpkg/sql/plan/explainpackage tests pass.Special notes for your reviewer: