fix only full group by - #26635
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.
Request changes: keep the newly allowed columns valid across the aggregate/window stage boundary.
A valid single-value exception fails to build as soon as that column is consumed by a window function:
SELECT deptno,
FIRST_VALUE(job) OVER (),
SUM(sal)
FROM constraint_test.emp
WHERE job = 'clerk'
GROUP BY deptno;Under ONLY_FULL_GROUP_BY, job is statement-wide single-valued, so this is the same deterministic case this PR is intended to allow. On exact head dbea0aaa827d, a planner regression expecting BuildPlan to succeed instead fails with Column remapping failed: cannot find column reference. The failing aggregate contains any_value(first_value(emp.job) over (...)): wrapBareColRefsInAnyValue walks every project after validation, sees the window-tag project as a bare column, and creates a pre-window aggregate that references a post-window result. Meanwhile, the raw window input also has to be materialized from the aggregate output.
Please rewrite allowed raw window arguments/partition/order expressions to group/aggregate outputs, while leaving the window-result tag above the aggregate stage. Add regressions for both exception shapes (WHERE-single-valued and PK-dependent) in window arguments/order keys. The PR's focused OFGB and sql-mode/prepared-cache tests pass, so this stage boundary is currently uncovered.
|
# Conflicts: # pkg/sql/plan/base_binder.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 7de4fc4. The previously reported aggregate/window stage-boundary failure is fixed: windowTag results remain above AGG, while allowed raw window arguments, PARTITION BY expressions, and ORDER BY expressions are materialized through aggregate outputs. I verified the focused planner/frontend regressions plus additional edge cases for window-only ORDER BY, isolated partition/order keys, nested scalar wrappers, mixed safe/unsafe columns, reverse equality, OR rejection, and ROLLUP. Build/vet and current CI are green. No blocking findings.
Merge Queue Status
This pull request spent 16 minutes 21 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks:
HintYou may have to fix your CI before adding the pull request to the queue again. 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:
issue #25327
What this PR does / why we need it:
未开启 ONLY_FULL_GROUP_BY:保持原有宽松行为。
开启且无 MATRIXONE_NATIVE:
同时包含 MATRIXONE_NATIVE:保持 MatrixOne 原生严格校验。
支持 SELECT、HAVING、ORDER BY,并处理组合主键、ROLLUP/CUBE、ENUM/SET、带点号列名等边界。
SQL mode 改变时清理普通计划缓存,并重建模式不匹配的 PREPARE 计划。
新增独立 BVT SQL/result 文件及 planner、frontend 回归测试。