Repository navigation
add json_contains - #25478
add json_contains#25478
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.
Requesting changes for two semantic blockers:
-
pkg/sql/plan/function/func_builtin_json.go:351-365+test/distributed/cases/function/func_json_contains.result:130-138jsonScalarsComparableonly treats exact sameTYPE()orINTEGER/DECIMALpairs as comparable. That excludes JSONDOUBLE, soJSON_CONTAINS(1,1.0),JSON_CONTAINS({"a":1},{"a":1.0}), and[1,2,3]vs[1.0,3.0]all return0and the new BVT locks that in. For MySQL-compatibleJSON_CONTAINS, numeric JSON scalars need numeric equality across INT/UINT/DOUBLE/DECIMAL, not type-equality except for int/decimal.- Suggested fix: reuse a numeric-aware scalar comparator for all numeric JSON types instead of the current
TYPE()/INTEGER-or-DECIMALgate.
-
pkg/sql/plan/function/func_builtin_json.go:238-245+pkg/container/bytejson/bytejson.go:461-507- The path branch uses
QuerySimpleExist(), and that helper returns “path not found” once it hits a scalar with an array-index leg. That drops MySQLs scalar[0]autowrap semantics for simple paths. Cases likeJSON_CONTAINS(1,1,$[0])orJSON_CONTAINS({"a":1},1,$.a[0])should match, but this implementation would returnNULL. - Suggested fix: either use the normal JSON path extractor for the third argument or extend
QuerySimpleExist()to honor the same scalar[0]autowrap rule.
- The path branch uses
已经修改 |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Rechecked the latest head after the requested fixes.
The previous semantic blockers are addressed:
- Numeric containment no longer reuses the general ordering comparator for equality. The new path has exact checks across int/uint/float/decimal cases, and the regressions for vs , large integers above 2^53, uint64 boundaries, and decimal/float cases are covered by UT/BVT.
- The third-argument path flow now uses a JSON_CONTAINS-specific simple-path lookup with scalar autowrap, without changing the existing QuerySimple/JSON modify behavior. Missing paths still return NULL, and wildcard/non-simple paths error as required.
I also checked the function registration/ID changes, strict/null handling, invalid JSON/path unhappy paths, typed JSON inputs, arrays/objects/scalars, and select-list skip behavior. CI is green, and I locally ran the targeted bytejson and function tests for the new code paths.
Approved.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Rechecked the latest head after the requested fixes.
The previous semantic blockers are addressed:
- Numeric containment no longer reuses the general ordering comparator for equality. The new path has exact checks across int/uint/float/decimal cases, and the regressions for
1vs1.000000009, large integers above 2^53, uint64 boundaries, and decimal/float cases are covered by UT/BVT. - The third-argument path flow now uses a JSON_CONTAINS-specific simple-path lookup with scalar
[0]autowrap, without changing the existing QuerySimple/JSON modify behavior. Missing paths still return NULL, and wildcard/non-simple paths error as required.
I also checked the function registration/ID changes, strict/null handling, invalid JSON/path unhappy paths, typed JSON inputs, arrays/objects/scalars, and select-list skip behavior. CI is green, and I locally ran the targeted bytejson and function tests for the new code paths.
Approved.
Merge Queue Status
This pull request spent 3 hours 48 minutes in the queue, including 2 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #24732
What this PR does / why we need it:
增加 json_contains函数