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? |
a311d35 to
bb601ed
Compare
|
Addressed XuPeng-SH's first P2 at exact head Changes:
Validation:
Remaining (not closed):
Please re-review this head. |
|
Local same-instance BVT acceptance evidence for exact head Environment: local single-CN Two consecutive executions of Key MySQL-conversion results (identical in Run 1 and Run 2):
Independent teardown after both runs: Also fixed a real bug found in host run: empty non-nil selectList made This closes the two same-instance BVT executions + independent teardown residue requirement. |
aptend
left a comment
There was a problem hiding this comment.
Deep re-review at exact head 0a4c46e against base/merge-base 5aa23ca: REQUEST_CHANGES. I read the prior reviews, inline thread, author replies, delta since my c2f5c81 review, and the full PR diff. The earlier strict-CAST result mismatch is addressed for SQL aggregate binding by json_agg_to_double; current public BVT and author same-instance teardown evidence cover those value cases. Two blockers remain:
-
[P2] pkg/sql/plan/function/func_cast.go:3001-3008 drops numeric-prefix truncation warnings. parseStringToFloat("12x", SQLCompatibilityMySQL) returns 12 with nil error because it consumes the decimal prefix, so this branch returns 12 without calling emit. Reproducer: aggregate a JSON string '"12x"' and inspect SHOW WARNINGS: the numeric result is 12 but the truncation warning promised by this MySQL-compatible aggregate boundary is absent. The repo already has appendNumericCoercionWarning for precisely this consumed-prefix case (func_cast.go:7110+); use equivalent detection here and add a warning-sink assertion. MySQL documents JSON numeric aggregation and numeric conversion/truncation behavior at https://dev.mysql.com/doc/refman/8.4/en/json.html and https://dev.mysql.com/doc/refman/8.4/en/type-conversion.html.
-
[P2 — exact-head validation] The new tests still assert the old contract, leaving required UT/coverage CI red. pkg/sql/plan/json_numeric_aggregate_test.go:259 demands a direct CAST for every window aggregate, but the new binder correctly places json_agg_to_double there; all six subtests fail. pkg/sql/plan/function/json_numeric_agg_test.go:167-168 unconditionally fails for sample aggregates even when the 'json-null-is-zero' case contains TWO contributing JSON nulls, so VAR_SAMP/STDDEV_SAMP validly return 0 rather than SQL NULL. Local CGO-enabled focused tests reproduced both failures, matching CI run 35810263731. Update those oracles to the new conversion and cardinality semantics and rerun the required jobs.
Local make thirdparties and git diff --check passed; the focused pkg/sql/plan and pkg/sql/plan/function tests failed only in the cases described above. No temporary test or main-worktree changes were retained.
Route SUM/AVG/VAR_*/STDDEV_* JSON operands through json_agg_to_double so booleans become 1/0, numeric-prefix strings keep their prefix, and JSON null/composites contribute 0 with warnings. Explicit CAST(json AS DOUBLE) keeps the strict JSON-to-DOUBLE contract.
A non-nil FunctionSelectList with an empty SelectList made Contains return false for every row, so the conversion appended only NULLs. Follow ShouldEvalAllRow like the other unary templates.
|
Updated in 092b721:
Validation: focused JSON function/planner tests passed; the full |
|
@XuPeng-SH CR follow-up at
Validation: focused tests (52 planner / 94 function test items), both full owning packages with The PR description now records this exact head and the remaining scope gaps. CI/reviewer approval, deployment QA, merge, and issue closure remain separate. Please re-review this head. |
aptend
left a comment
There was a problem hiding this comment.
Deep re-review at exact head 3de957a54b433492d204802edb75e77d5ca21492 against merge-base b9013dc6bb058ec74935a62ac3a35f57d13c2f98: APPROVE. I read the full 11-file PR diff, prior reviews, the resolved inline thread and all author replies, and compared the changes since my previous 0a4c46e993 review (accounting for the rebase).
The previous blockers are closed in code, not merely by the replies: pkg/sql/plan/function/func_cast.go:3036-3130 now routes JSON numeric-aggregate values through warning conversion; its string case uses appendNumericCoercionWarning, so a JSON string "12x" contributes 12 and emits diagnostic 1292 while SQL NULL is skipped and JSON null contributes zero. pkg/sql/plan/base_binder.go:3824-3850 applies this to ordinary and prepared/window aggregate binding, including VARIANCE/STD/STDDEV aliases that the prior candidate missed; explicit CAST remains on its separate strict path. pkg/sql/plan/base_binder.go:10030-10040 retains nullable metadata for JSON→numeric CAST in the DISTINCT rewrite. The new/updated function and planner UTs cover the previous warning-sink, window, sample-cardinality, and alias failures; the public BVT covers mixed values, DISTINCT null-only groups, explicit CAST control, and SHOW WARNINGS. The new function ID 584 is registered and below FUNCTION_END_NUMBER 585.
git diff --check passed. The author reports two same-instance BVT passes with independent teardown checks; I inspected the canonical SQL/result pair but did not independently run a service. The fresh exact-head CI UT, coverage, SCA, and two BVT topology jobs are still running at review time, so this approval does not claim those checks have passed. Prepared/View/CTAS, real spill/remote, and cross-CN warning propagation remain documented follow-up QA, not proven by this review. I found no remaining blocking defect in this PR's scoped implementation.
|
Conflict and exact-head coverage repair are published at 1df5f1a. The merge parent is current main d8152cb; the function-ID collision preserves main JSON_DEPTH=584 and assigns the new internal JSON_AGG_TO_DOUBLE function ID 585. Added branch-complete unit coverage for JSON numeric aggregate scalar kinds, malformed values, selection masks, all-null batches, and arity validation. With workspace-local third-party artifacts, focused function/planner tests pass; changed-function coverage is 100% for jsonAggToFloat64 and 83.3% for JsonAggToDouble. Fresh CI has started on this head. No re-review or merge is requested by this update. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review at 1df5f1a: APPROVE within the stated numeric-aggregate scope. All 11 changed files, prior reviews, existing binder/aggregate/conversion owners and warning-aware constant folding reviewed. No CI wait.
Historical blockers are closed: explicit CAST nullability remains correct for DISTINCT; aggregate JSON coercion uses the dedicated warning conversion; numeric-prefix diagnostics use the existing warning owner; ordinary/prepared/window aliases converge on that boundary; sample cardinality and stale window test expectations are corrected. Author evidence for two BVT passes and independent same-instance teardown was reviewed, not rerun as a full BVT here.
Independent exact-head black-box challenge used a real embedded CN/TN cluster and MySQL client. Mixed JSON null, prefix string, array and SQL NULL produced SUM=12, AVG=4, VAR_POP=32 and VAR_SAMP=48, with 1265/1292 diagnostics. Checked window running totals, DISTINCT, empty input, repeat SQL PREPARE, and one binary prepared statement with null→2→array→3 parameters (0→8→0→12 over four rows), including diagnostics clearing on valid input. Explicit strict CAST still errors and the same connection immediately returns SELECT 1. Controlled-CGo integration run passed (scenario 11.51s).
Design: one conversion boundary before existing DOUBLE aggregate executors is proportionate; no new aggregate state machine or storage path is needed. The low-level direct type matcher still uses strict CAST, so future direct binder callers must not bypass the SQL coercion owner. I found no reachable new caller defect in this review.
Nonblocking cleanup: the unused diagnostic boolean returned by jsonAggToFloat64 is misleading when named gotNull in tests; simplify or give it a real owner. TestJSONNumericAggCastErrorsDoNotPoisonRetry currently exercises neither an error nor a retry; rename it to its actual NULL-control behavior or replace it with a real recovery assertion. Consolidate such tests instead of extending duplicate setup.
This review does not claim real spill/cross-CN warning transport, View/CTAS or deployment QA, and does not close #28868.
Merge Queue Status
This pull request spent 1 hour 20 minutes 59 seconds in the queue, with no time running CI. ReasonPull request #28946 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.
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. Waiting for any of
All conditions
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 #28868
What this PR does / why we need it:
Numeric aggregates over JSON use a dedicated MySQL numeric-context conversion before the existing DOUBLE aggregate executors. JSON null, arrays and objects contribute zero with warnings; booleans contribute 1/0; numeric-prefix strings retain their numeric prefix and a truncation diagnostic. SQL NULL is skipped. Explicit numeric CAST retains its separate existing semantics and nullable metadata.
The CR repair preserves the warning for a JSON string such as
"12x"(SUM=12; SHOW WARNINGS reports 1292), corrects window-plan assertions to checkJSON_AGG_TO_DOUBLE, and fixes the sample-aggregate oracle: two contributing JSON nulls are two zeros, so VAR_SAMP/STDDEV_SAMP return zero, while fewer than two contributing values return SQL NULL.Follow-up SQL planner regressions exposed that VARIANCE/STD/STDDEV bypassed the numeric-context conversion. Their names now enter the same existing coercion boundary as VAR_POP/STDDEV_POP. Regression tests exercise ordinary and window SQL binding, warning-sink precedence and diagnostic codes, SQL NULL versus JSON null, and effective sample cardinalities 0/1/2. No new function ID, executor, public API, storage format or configuration is added by this follow-up.
Validation at
3de957a54b433492d204802edb75e77d5ca21492(baseb9013dc6bb058ec74935a62ac3a35f57d13c2f98):092b7215ddb744f77863e1097c121f151cd72d8a.pkg/sql/planandpkg/sql/plan/functiontests with-count=1, andgo vetfor both packages.git diff --check.The BVT execution also exposed stale DOUBLE metadata in the expected output:
[8,54,0]was corrected to[8,53,31], with numeric values, NULL behavior, warning text/code, and explicit CAST control unchanged.Canonical BVT:
test/distributed/cases/function/func_aggr_json_numeric.sqland.result. It covers mixed numeric/JSON-null/SQL-NULL results (AVG=1.625), DISTINCT null-only groups, sibling aggregates, explicit CAST control, window SUM, the prefix warning, and alias equivalence.QA required: yes. Prepared statements, View/CTAS, real spill, cross-CN warning transport, deployment QA, and complete MySQL diagnostic parity for other JSON values remain outside this scoped acceptance. Intermediate-state round-trip UT is not real spill/remote evidence. This PR remains Ready for re-review and does not close the issue.