-
Notifications
You must be signed in to change notification settings - Fork 2.3k
evalengine: make JSON_EXTRACT work with non-static arguments
#19035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Signed-off-by: Arthur Schreiber <[email protected]>
Signed-off-by: Arthur Schreiber <[email protected]>
Signed-off-by: Arthur Schreiber <[email protected]>
65ff0d1 to
4153731
Compare
Signed-off-by: Arthur Schreiber <[email protected]>
| regexp.MustCompile(`Illegal argument to a regular expression`), | ||
| regexp.MustCompile(`Incorrect arguments to regexp_substr`), | ||
| regexp.MustCompile(`Incorrect arguments to regexp_replace`), | ||
| regexp.MustCompile(`Invalid JSON path expression\. The error is around character position (\d+)\.`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's currently some differences in the error messages generated by the evalengine vs what MySQL generates when JSON Path parsing runs into issues.
For now, I'd like to ignore these differences - but I do believe we should be able to change our implementation in the future to mimic MySQL more closely.
Signed-off-by: Arthur Schreiber <[email protected]>
|
📝 Documentation updates detected! New suggestion: Add changelog entry for JSON_EXTRACT dynamic path arguments |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19035 +/- ##
==========================================
+ Coverage 69.81% 69.88% +0.06%
==========================================
Files 1610 1610
Lines 215362 215498 +136
==========================================
+ Hits 150358 150601 +243
+ Misses 65004 64897 -107 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Arthur Schreiber <[email protected]>
|
I had to push another fix for "static" but generated JSON Paths, like |
| yield(`JSON_EXTRACT('{"a": 1}', '$.a')`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1}', '$.*')`, nil, false) | ||
| yield(`JSON_EXTRACT('[1, 2, 3]', '$[0 to 2]')`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1, "b": 2}', '$.a', '$.b')`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1}', '$.a', '$.z')`, nil, false) | ||
|
|
||
| yield(`JSON_EXTRACT(CONCAT('{', '"a"', ':', ' ', '1', '}'), '$.a'))`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1}', CONCAT('$', '.', 'a'))`, nil, false) | ||
|
|
||
| yield(`JSON_EXTRACT(NULL, '$.a')`, nil, false) | ||
| yield(`JSON_EXTRACT(NULL, NULL)`, nil, false) | ||
|
|
||
| yield(`JSON_EXTRACT('{"a": 1}', NULL)`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1}', '$.a', NULL)`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1}', NULL, '$.a')`, nil, false) | ||
|
|
||
| yield(`JSON_EXTRACT('{"a": 1}', '$.b')`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1}', '$.b', '$.c')`, nil, false) | ||
| yield(`JSON_EXTRACT('[1,2,3]', '$[10]')`, nil, false) | ||
|
|
||
| yield(`JSON_EXTRACT('{invalid}', '$.a')`, nil, false) | ||
| yield(`JSON_EXTRACT('not json', '$.a')`, nil, false) | ||
| yield(`JSON_EXTRACT('', '$.a')`, nil, false) | ||
| yield(`JSON_EXTRACT('{invalid}', NULL)`, nil, false) | ||
|
|
||
| yield(`JSON_EXTRACT('{"a": 1}', '$.b[ 1 ].')`, nil, false) | ||
|
|
||
| yield(`JSON_EXTRACT(NULL, 'invalid-path')`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1}', NULL, 'invalid-path')`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1}', 'invalid-path', NULL)`, nil, false) | ||
| yield(`JSON_EXTRACT('{"a": 1}', '$.a', 'invalid')`, nil, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these could be handled by adding them to inputJSONObjects or inputJSONPaths, but that then highlights bugs in JSON_KEYS and JSON_CONTAINS, which I want to focus on in separate PRs.
Signed-off-by: Arthur Schreiber <[email protected]>
Signed-off-by: Arthur Schreiber <[email protected]>
Description
Compiled
JSON_EXTRACTfunctions currently do not work when arguments are not static (e.g. bind variables or the result of another function call).This updates the compiler to handle non-static arguments, and also fixes null handling to match what MySQL is doing.
Static JSON path arguments are still optimized in the updated version, even when intermixed with non-static arguments.
Related Issue(s)
See #9647
Checklist
Deployment Notes
AI Disclosure