Repository navigation
add missing functions - #24509
add missing functions#24509
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.
Found two blocking issues in the new JSON functions:
json_schema_valid/json_schema_validation_reportonly register(VARCHAR, VARCHAR)and(JSON, JSON)overloads inpkg/sql/plan/function/list_builtIn.go, but the implementations already handleschemaIsStranddocIsStrindependently inpkg/sql/plan/function/func_builtin_json.go. Mixed calls likejson_schema_valid('{\"type\":\"number\"}', json_col)andjson_schema_validation_report(json_schema_col, '{\"a\":1}')currently fail during function resolution. I verifiedGetFunctionByName(..., [VARCHAR, JSON])and[JSON, VARCHAR]both returninvalid argument function ... bad value [...]. Please add the mixed overloads and cover them with tests.\n\n2.JsonValuecurrently returns JSON text for non-scalar matches. Inpkg/sql/plan/function/func_builtin_json.go, afterval := bj.Query(...), the code only checksval.IsNull()and otherwise always callsval.Unquote(). When the path resolves to an object/array,Unquote()falls back tobj.String(), soJSON_VALUE('{\"a\":[1]}', '$.a')returns[1]instead of SQL NULL.JSON_VALUEshould stay scalar-only here, so object/array matches need to return NULL (and ideally get a regression test too).
|
已继续把之前列出的每个函数问题修掉,并补了测试/结果文件。 16:13:22 [12/971] 改动内容:
已通过测试: |
|
• 审查结论 这轮按你要求把 PR 24509 的 10 个目标函数逐个过了一遍,并且遵守了“当前函数彻底处理完再看下一个”。 最终结论是:当前分支上这 10 个函数没有剩余确认问题了。
这 5 个函数原先都会在“整列都应直接返回 SQL NULL”时,仍然先尝试解析输入;我已经在 /mnt/fastdata/matrixone/pkg/sql/plan/function/func_builtin_json.go 里补了 fast path,并在 /mnt/fastdata/matrixone/pkg/sql/plan/function/func_json_valid_test.go 里加了对应回归测试。 其余 5 个函数在当前分支里已经是修好的状态,我逐个确认后没有再改代码:
其中也一并确认了这几类更早的问题在当前分支都已经到位:
验证 我跑了每个函数对应的定向 go test,以及最后一轮聚合验证,全部通过。 如果你要,我下一步可以把这次审查整理成一份适合直接发 PR review comment 的精简版结论。 |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Current head still has several blocking JSON semantic issues:
-
JSON_KEYSis still registered and materialized asVARCHAR, notJSON.pkg/sql/plan/function/list_builtIn.goregisters allJSON_KEYSoverloads withretType = types.T_varchar.pkg/sql/plan/function/func_builtin_json.gobuilds a JSON array text (buildJsonKeysArray) and appends it viaAppendMustBytesValue, so downstream composition treats it as a string, not a JSON value.- This breaks nesting semantics, e.g.
JSON_ARRAY(JSON_KEYS('{"a":1}'))becomes an array containing the string"["a"]"instead of a nested JSON array.
-
JSON_SCHEMA_VALIDATION_REPORTis also exposed asVARCHAR, and its payload shape is not the MySQL-compatible report contract.pkg/sql/plan/function/list_builtIn.goregistersJSON_SCHEMA_VALID_REPORTwithretType = types.T_varchar.pkg/sql/plan/function/func_builtin_json.goreturns a custom payload like{"valid": false, "errors": [...]}frombuildSchemaValidationReport().- This locks in the wrong contract and the wrong type for a function that should produce a JSON report document.
-
JSON_VALUEstill accepts non-simple / wildcard paths and silently turns multi-match cases intoNULL.pkg/sql/plan/function/func_builtin_json.goonly parses the path, but never rejects wildcard / non-simple paths beforebj.Query(...).- When such a path yields an object/array, the implementation falls into the
object/array => NULLbranch instead of rejecting the path / multiple-match case.
These are all correctness / contract issues for newly added builtins, so I’m requesting changes.
• 继续这轮后,我把你补充指出的 3 个漏审点都落成了代码和测试,并把分布式基线文件也一并补了。 这次新增的核心修复是:
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed from multiple angles, including function registration, JSON constructor/extractor semantics, schema-validation paths, typed-scalar bytejson behavior, cross-type numeric comparison, test coverage, and current unresolved threads.
I did not find any remaining blocking issues on the current head. Approving.
Merge Queue Status
This pull request spent 43 seconds in the queue, including 4 seconds running CI. Required conditions to merge
|

What type of PR is this?
Which issue(s) this PR fixes:
issue #24481 #24486
What this PR does / why we need it:
补充缺失的json函数.
json_value 还缺少returning等语法.后续pr加