[CALCITE-2870] Support for JSON query quotes behavior#1107
[CALCITE-2870] Support for JSON query quotes behavior#1107ritesh-kapoor wants to merge 3 commits intoapache:masterfrom ritesh-kapoor:CALCITE-2870
Conversation
| "[100]", "VARCHAR(2000)"); | ||
|
|
||
| //omit quotes test | ||
| tester.checkString("json_query('{\"foo\":\"100\"}', 'strict $.foo' " |
There was a problem hiding this comment.
For comparing the behaviors, could you please add a case for the flag KEEP QUOTES?
There was a problem hiding this comment.
unless RETURNING text is defined KEEP QUOTES doesn't functionally changes anything. Please help me understand if it is incorrect or should we implement RETURNING functionality as well.
There was a problem hiding this comment.
@ritesh-kapoor Thanks for your clarification, and sorry for the late reply.
if it is incorrect or should we implement RETURNING functionality as well
Here is the SQL:2016 standard's JSON part:
https://standards.iso.org/ittf/PubliclyAvailableStandards/c067367_ISO_IEC_TR_19075-6_2017.zip
In the std, JSON_QUERY does include a optional output clause:
<JSON output clause> ::= RETURNING [ FORMAT <JSON representation> ]
So yes I think the functionality should be implemented as well, maybe by a separated PR/JIRA.
Besides, I recall that currently JSON_QUERY is not designed for returning scalar values (see examples in page 34 in std). It only returns JSON array or object, otherwise an error is thrown. But the highlighted case your wrote shows that a JSON_QUERY call produces an scalar string in the PR.
So in the PR the behavior on querying a scalar string is:
- If
OMIT QUOTESis specified, return a string value; - If
KEEP QUOTESis specified, report an error; - If quote behavior is not specified, report an error.
Did I summarize them correctly? If yes, I think case 1 and case 2/3 are not consistent. Maybe we should make JSON_QUERY be able to return scalar values as well as JSON_VALUE by default (without abiding by the std). Have you checked how does the same part work in other SQL impelemtations such as DB2[1]? Does it ban scalar value for JSON_QUERY too?
There was a problem hiding this comment.
I can raise a separate PR for the optional clause for JSON_QUERY. Also
- If OMIT QUOTES is specified, return a string value;
- If KEEP QUOTES is specified, the function would behave as if it was unspecified.
- If quote behavior is not specified, the function would behave as if it was unspecified.
Got some references : https://marc.info/?l=postgresql-hackers&m=153024002012585&w=2
Sorry this PR is pending for long, I will also resolve all the conflicts once it is ready to be merged.
80f411d to
ca27fe9
Compare
No description provided.