[ 
https://issues.apache.org/jira/browse/CALCITE-2884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stamatis Zampetakis resolved CALCITE-2884.
------------------------------------------
    Resolution: Fixed

Apart from rebasing and resolving conflicts I had to do some slight changes in 
the code to address checkstyle, errorprone, and checker framework failures.
 
Fixed in 
https://github.com/apache/calcite/commit/787aa9eeaf7bbcb20f016de1ea1e9df09aaa5dcf.
 Thanks for the PR [~x1q1j1]! 

> Implement JSON_INSERT, JSON_REPLACE, JSON_SET
> ---------------------------------------------
>
>                 Key: CALCITE-2884
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2884
>             Project: Calcite
>          Issue Type: Sub-task
>            Reporter: Forward Xu
>            Assignee: Forward Xu
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.33.0
>
>          Time Spent: 9h 10m
>  Remaining Estimate: 0h
>
> {{JSON_INSERT(jsondoc}}, _{{path}}_, _{{val}}_[, path, val] )
> {{JSON_REPLACE(jsondoc}}, _{{path}}_, _{{val}}_[, path, val] )
> {{JSON_SET(jsondoc}}, _{{path}}_, _{{val}}_[, path, val] )
> Inserts data into a JSON document and returns the result. Returns {{NULL}} if 
> any argument is {{NULL}}. An error occurs if the _{{json_doc}}_ argument is 
> not a valid JSON document or any _{{path}}_ argument is not a valid path 
> expression or contains a  *or {{}}}}*{{{{*}} wildcard.
> The path-value pairs are evaluated left to right. The document produced by 
> evaluating one pair becomes the new value against which the next pair is 
> evaluated.
> A path-value pair for an existing path in the document is ignored and does 
> not overwrite the existing document value. A path-value pair for a 
> nonexisting path in the document adds the value to the document if the path 
> identifies one of these types of values:
>  * A member not present in an existing object. The member is added to the 
> object and associated with the new value.
>  * A position past the end of an existing array. The array is extended with 
> the new value. If the existing value is not an array, it is autowrapped as an 
> array, then extended with the new value.
> Otherwise, a path-value pair for a nonexisting path in the document is 
> ignored and has no effect.
> For a comparison of 
> [{{JSON_INSERT()}}|https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-insert],
>  
> [{{JSON_REPLACE()}}|https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-replace],
>  and 
> [{{JSON_SET()}}|https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-set],
>  see the discussion of 
> [{{JSON_SET()}}|https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-set].
> JSON_INSERT SQL:
> {code:java}
> SELECT JSON_INSERT(v, '$.a', 10, '$.c', '[true, false]') AS c1
>  FROM (VALUES ('{ "a": 1, "b": [2, 3]}')) AS t(v);{code}
> Result:
> ||c1||
> |{"a": 1, "b": [2, 3], "c": "[true, false]"}|
> JSON_REPLACE SQL:
> {code:java}
> SELECT JSON_REPLACE(v, '$.a', 10, '$.c', '[true, false]') AS c1
>  FROM (VALUES ('{ "a": 1, "b": [2, 3]}')) AS t(v);{code}
> Result:
> ||c1||
> |{"a": 10, "b": [2, 3],}|
> JSON_SET SQL:
> {code:java}
> SELECT JSON_INSERT(v, '$.a', 10, '$.c', '[true, false]') AS c1
>  FROM (VALUES ('{ "a": 1, "b": [2, 3]}')) AS t(v);{code}
> Result:
> ||c1||
> |{"a": 10, "b": [2, 3], "c": "[true, false]"}|
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to