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.
Request changes
High: the new FLOAT64 normalization returns wrong results for valid JSON numbers
adjustJsonOrderingDynamicParamType casts both operands to FLOAT64. The binary protocol preserves a MYSQL_TYPE_LONGLONG / unsigned integer parameter as its exact decimal text, but the generated casts then round both that text and an exact JSON integer.
Concrete regression:
SELECT JSON_EXTRACT('{"v":9007199254740992}', '$.v') < ?
-- binary parameter: MYSQL_TYPE_LONGLONG, value 9007199254740993The predicate must be true. With this patch both casts produce 9007199254740992 as float64, so it evaluates to false. The same loss occurs for high-precision decimal JSON values. This conflicts with the existing pkg/container/bytejson/bytejson_compare_test.go contract that values beyond the exact float range must not collapse, and with the PR issue's MySQL-compatibility goal.
The fix needs an exact comparison path rather than choosing an approximate common type. Preserve the parameter's JSON/numeric representation through execute and compare JSON numeric scalars exactly (including int64, uint64, and decimal), or add a dedicated exact JSON ordering comparator. Do not coerce both sides to FLOAT64.
Please add protocol-level regression coverage for the adjacent 2^53 integers above, a high-precision decimal pair, NULL, invalid MYSQL_TYPE_VAR_STRING, and both operand orders. The current tests only prove that the binder emits casts and that "1" can be cast; they do not execute the complete prepared comparison semantics.
I also ran the PR's added plan/colexec/frontend tests plus the relevant JSON exact-comparison and cast tests locally.
…json-extract-prepare-param # Conflicts: # pkg/sql/plan/function/function_id.go
…json-extract-prepare-param # Conflicts: # pkg/sql/plan/function/func_compare_test.go # pkg/sql/plan/function/function_id.go # pkg/sql/plan/function/function_id_test.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Previous precision blocker is fixed in the latest head.
The new path no longer collapses JSON ordering through FLOAT64: direct prepared params are normalized via __mo_json_ordering_param, binary-protocol values keep their exact text representation, and JSON ordering now compares exact JSON numeric scalars (including adjacent >2^53 integers, uint64 edge values, decimals, null, invalid input, and both operand orders) instead of approximate float casts.
I re-checked the binder/operator/runtime chain and I don't see a remaining high-confidence correctness blocker in this PR.
Merge Queue Status
This pull request spent 1 hour 1 minute 34 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #25527 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
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #25502
What this PR does / why we need it:
Prepared JSON ordering predicates such as
json_expr >= ?were rejected during binding because the dynamic parameter kept its default text type while JSON ordering is only supported through numeric comparison.This change detects direct dynamic parameters on either side of JSON ordering operators, casts the JSON expression to
float64, and assigns the parameter the same type. Literal string comparisons remain rejected.Tested with:
go test -count=1 -mod=mod ./pkg/sql/plan -run TestBindFuncExprImplByPlanExpr_JsonOrderingWithDynamicParam