mrhhsg opened a new pull request, #67804:
URL: https://github.com/apache/doris/pull/67804
### What problem does this PR solve?
Issue Number: None
Problem Summary:
`json_set`, `json_insert` and `json_replace` (and their `jsonb_*` aliases)
take a
JSON document followed by path/value pairs, so the argument count must be
odd.
The FE only checked `arity >= 3`, so a call whose last path had no value,
e.g.
`json_set('{}', '$.a', 1, '$.b')`, passed analysis and `EXPLAIN` succeeded.
The
error was only raised by the BE at execution time:
```
[INVALID_ARGUMENT]Function jsonb_set must have an odd number of arguments
and more than 2 arguments, but got: 4
```
The total argument count is known at analysis time, so this PR adds
`checkLegalityBeforeTypeCoercion` to the three functions and rejects an even
argument count with a clear `AnalysisException` before type coercion and the
`to_json` rewrite. The BE check is kept as a defensive fallback.
### Release note
None
### Check List (For Author)
- Test:
- Unit Test:
`CheckExpressionLegalityTest#testJsonModifyFunctionsRejectEvenArity`
- Regression test: `test_query_json_set`, `test_query_json_insert`,
`test_query_json_replace`
(4/6-argument rejection including `EXPLAIN` and the `jsonb_*` aliases,
legal 3/5-argument calls)
- Behavior changed: Yes (an even argument count is now rejected during FE
analysis instead of failing at BE execution)
- Does this need documentation: No
https://claude.ai/code/session_016LqgBtqMHamfbXB2sCDnuu
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]