Repository navigation
fix(window): support temporal interval frame parameters and string parsing - #30310
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? |
|
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: f55f486031e8ceaaace9be6b20cbdcf44d17c3ea
Assessment: request_changes
Reviewed the complete 13-file delta and affected callers. Preserving source types and normalizing execution-owned frames is reasonable, but two confirmed gaps remain: LIMIT 0 bypasses parameter validation, and NULL interval bounds cause quadratic aggregation over NULL-key peers.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
-
P2
pkg/sql/colexec/window/window.go:163: Prepare SELECT SUM(v) OVER(ORDER BY at RANGE INTERVAL ? SECOND PRECEDING) FROM d LIMIT 0, then execute with -1, NULL, or 9223372036854.775808.
Impact: Both SQL EXECUTE and binary prepared execution succeed instead of rejecting these invalid bounds, violating the stated validation contract for empty inputs. Ensure validation occurs before the LIMIT 0 shortcut can omit the window operator.
Evidence: Validation runs only during Window.Prepare, but compile.go:1956 returns an empty scope without constructing that operator. TestReviewWindowLimitZeroValidation reproduced all six invalid executions returning success; literal-negative and valid-recovery controls passed. Constant-false-filter controls also rejected invalid parameters correctly. See limit-zero.log and checks/1792089047532003971-2.json, exit 1. -
P2
pkg/sql/colexec/window/window.go:850: Evaluate SUM or AVG over a temporal RANGE frame with a NULL-producing interval such as '00:01.5' MINUTE_SECOND and a large NULL ORDER BY peer group.
Impact: Disabling sliding aggregation globally makes the generic evaluator aggregate the entire NULL peer group separately for every output row, producing quadratic work. Preserve peer-result reuse while retaining empty frames for non-NULL keys.
Evidence: At 4,096 NULL-key rows, focused operator medians were 295.66 ms on HEAD versus 0.167 ms with the frozen-base window evaluator; HEAD's zero-bound control took 0.179 ms. Increasing rows from 1,024 to 4,096 increased NULL-bound time from 17.75 ms to 295.66 ms. Public SQL confirmed 288.06 ms versus 5.70 ms for the equivalent zero-bound control, with every sum checked. See bench-head.log, bench-base.log and public-boundaries.log; receipts 1792088803529159625-2, 1792088818148506306-2 and 1792088929628102712-2.
Validation:
-
Artifacts are retained under /home/xupeng/.local/state/mo-bot/jobs/0945a8b21491518418b4b0a6/attempt-1. review-evidence-audit.json reconciles 11 command/source/exit receipts with logs and overlay hashes; audit receipt checks/1792089171450663858-2.json exited 0.
-
Full types, window and plan package suites passed: 4,149 passing test roots and two existing skipped subtests. All changed test roots executed. Receipt checks/1792088818593084402-2.json; packages.jsonl.
-
TestWindowTemporalIntervals passed all subtests through the SQL frontend, including prepared reuse, precision boundaries, empty-table validation and NULL peers. Additional prepared compound-reuse and DATE_ADD controls passed.
-
Constant string-expression failures also occurred with the base binder and were excluded from findings.
-
Isolation preflight passed; native recovery verified 192 current inputs, 62 artifacts and successful build-owner receipts. Exact HEAD, complete patch, clean source, formatting and whitespace checks passed.
-
Frozen CI reports 13 successful, 15 skipped and two neutral checks. No CI was rerun.
Limitations:
-
Benchmark comparison replaces only window.go with its frozen-base version; it is not a full-base build. Measurements are focused diagnostic samples, not production throughput estimates.
-
Linked issue bodies and raw author-validation artifacts were not supplied.
-
No local mo-tester comparison or fresh distributed/race suite was run. Public SQL tests exercised the existing one-CN fixture.
|
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: 35b8fce0d89f9015fa103b1d6ea849619bf49ab5
Assessment: approve
Reviewed the complete 18-file delta and affected callers. Shared normalization, execution-owned frames and pre-source validation form a coherent design. Boolean parameters now preserve numeric 0/1 semantics, and the previous LIMIT 0 and quadratic NULL-peer concerns are closed. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
TestWindowTemporalIntervals passed through the real frontend, covering SQL/binary prepared reuse, Boolean values, invalid-input recovery, empty inputs, LIMIT 0 variants and NULL peers. frontend.log and receipt 1792113754706061459-38.json record exit 0.
-
TestWindowIntervalBooleanMaterialization passed all six SECOND/DAY cases, distinguishing TRUE, FALSE and SQL NULL while preserving the source plan. boolean-unit.log and receipt 1792113778182932970-3.json record exit 0.
-
Independently reconciled retained receipts, logs, overlays and relevant source inputs for ten focused test roots, additional source-domain/admission probes and NULL-peer benchmarks. The historical Boolean failures were treated as failed-before controls.
-
Unchanged aggregation benchmarks measured NULL-peer medians of 0.0529 ms at 1,024 rows and 0.2135 ms at 4,096 rows; the 4,096-row zero-bound control measured 0.1797 ms. Admission adds bounded plan traversal and scalar normalization, without per-row parsing.
-
Isolation preflight passed. Native recovery verified 192 current inputs and 62 artifacts before completing the repository build owner. The initial missing-library setup failure ran no product tests.
-
review-evidence-audit.json under /home/xupeng/.local/state/mo-bot/jobs/10052ac1a6518cbf25e7d3bb/attempt-1 reconciles execution evidence and source hashes; audit receipt 1792113863319530898-4.json passed. Source remains unchanged. Supplied exact-head CI reports successful build, unit, static-analysis and multi-CN BVT checks.
Limitations:
-
Linked issue bodies and raw author/CI execution artifacts were not supplied; local_validation was empty.
-
Broad package, race and distributed coverage relies on supplied CI summaries and applicable retained evidence. No fresh mo-tester run or end-to-end SQL performance benchmark was performed; aggregation measurements are diagnostic samples.
Merge Queue Status
This pull request spent 1 hour 59 minutes 54 seconds in the queue, including 1 hour 3 minutes 42 seconds running CI. Required conditions to merge
|
…aefe08b16ded4738067ab21c3e6b5bab351bc49
What type of PR is this?
Which issue(s) this PR fixes:
Please keep both issues open after merge for verification by the reporter.
What this PR does / why we need it:
Temporal RANGE frames currently reject
INTERVAL ? SECONDduring PREPARE. Window interval strings also diverge from MySQL: full compound SECOND-ending values with an extra fractional field produce a duration, and a nonnumeric simple-unit string becomes a MaxInt64 sentinel that fails during execution.Keep each prepared interval's source type and original unit in the reusable plan, then normalize fresh frame values for each execution. Boolean parameters use numeric 0/1 offsets through both SQL EXECUTE and binary prepared execution, matching Boolean literals and integer parameters. Numeric SECOND parameters support fractional microseconds; negative, NULL, non-finite and overflowing values fail before input is consumed, including empty inputs and literal, outer-query, CTE and parameterized LIMIT 0 shortcuts. Window-specific string normalization treats excess compound fields as NULL arithmetic and a missing numeric prefix in a simple-unit string as zero. NULL interval arithmetic produces empty frames for non-NULL keys while preserving NULL-key peers. The ordinary, timestamp civil-time and sliding aggregate paths handle these frames consistently. SUM/AVG retain sliding peer state across empty intervals, output chunks and partition transitions, avoiding repeated aggregation of NULL-key peers.
Validation on Go 1.27.1, macOS arm64:
pkg/container/types,pkg/sql/plan,pkg/sql/colexec/window, andpkg/sql/compile(all four rerun after rebasing this follow-up onto official main).TestWindowTemporalIntervalsthrough the existing embedded one-CN fixture: SQL and binary prepared reuse, decimal128/microsecond boundaries, invalid values and recovery, empty input, LIMIT 0 admission, date/time/datetime/timestamp results, and NULL-key COUNT/SUM/AVG peers; the complete updated fixture passed in 5.99 seconds after rebasing onto official main.-race -tags matrixone_test -short -count=1, including cancellation, cleanup and reuse.go vet,golangci-lint(zero issues), formatting and diff checks.window_interval_parameters.sqlpassed normal mo-tester comparison twice on the same embedded one-CN instance (36/36 statements each, none skipped), including Boolean literal and prepared offsets. The test database was absent after each round; the SQL/binary integration fixture and these BVT runs completed together in 6.40 seconds.window_frame_order.sqlpassed normal mo-tester result comparison twice on the same embedded one-CN instance (9/9 statements each, none skipped), using CI runner revision309a0ca650e0c55e90292767fd61e4976818d66d. The negative-interval oracle now uses temporal ordering; positive and negative interval bounds on numeric ordering retain separate exact domain-error assertions. Other distributed coverage remains subject to CI.BenchmarkNullIntervalRangePeers: one warm-up followed by three measured rounds (-benchtime=10x -count=3), with every sum checked. At 1,024/4,096 NULL-key rows, NULL-bound medians changed from 12.837/212.678 ms before this follow-up to 0.0403/0.1527 ms after it. Scaling for four times as many rows improved from 16.57x to 3.79x; the updated zero-bound control took 0.1471 ms at 4,096 rows. These isolate aggregate work from sorting and are diagnostic samples rather than production throughput estimates. The final benchmark additionally checks output length/NULL status and releases state immediately on assertion failure.Execution admission validates finite bounds before source initialization; Window.Prepare creates execution-owned runtime frames. Work is bounded by reachable plan size and scalar text length, without per-row parsing. General
NormalizeIntervaland DATE_ADD behavior are unchanged. Nested parameter expressions such asINTERVAL (? + 1) SECONDremain unsupported; existing numeric literal rounding beyond six fractional digits is outside this change, while new dynamic SECOND bounds truncate to microseconds.