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

Forward Xu updated CALCITE-3130:
--------------------------------
    Summary: Implement JSON_UNQUOTE, JSON_QUOTE function  (was: Implement 
JSON_UNQUOTE, JSON_QUOTE)

> Implement JSON_UNQUOTE, JSON_QUOTE function
> -------------------------------------------
>
>                 Key: CALCITE-3130
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3130
>             Project: Calcite
>          Issue Type: Sub-task
>            Reporter: Forward Xu
>            Assignee: Forward Xu
>            Priority: Major
>
> [{{JSON_QUOTE(_{{string_}})}}|https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-quote]
> Quotes a string as a JSON value by wrapping it with double quote characters 
> and escaping interior quote and other characters, then returning the result 
> as a {{utf8mb4}}string. Returns {{NULL}} if the argument is {{NULL}}.
> This function is typically used to produce a valid JSON string literal for 
> inclusion within a JSON document.
> SQL:
> {code:java}
> SELECT JSON_QUOTE('null'), JSON_QUOTE('"null"');
> {code}
> Result:
> ||Heading 1||Heading 2||
> |"null"|"\"null\""|
> [{{JSON_UNQUOTE(_{{json_val_}})}}|https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-unquote]
> Unquotes JSON value and returns the result as a {{utf8mb4}} string. Returns 
> {{NULL}} if the argument is {{NULL}}. An error occurs if the value starts and 
> ends with double quotes but is not a valid JSON string literal.
> Within a string, certain sequences have special meaning unless the 
> [{{NO_BACKSLASH_ESCAPES}}|https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_no_backslash_escapes]
>  SQL mode is enabled. Each of these sequences begins with a backslash ({{}}), 
> known as the _escape character_. MySQL recognizes the escape sequences shown 
> in [Table 12.22, “JSON_UNQUOTE() Special Character Escape 
> Sequences”|https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#json-unquote-character-escape-sequences].
>  For all other escape sequences, backslash is ignored. That is, the escaped 
> character is interpreted as if it was not escaped. For example, {{\x}} is 
> just {{x}}. These sequences are case-sensitive. For example, {{\b}} is 
> interpreted as a backspace, but {{\B}} is interpreted as {{B}}.
> SQL:
> {code:java}
> SELECT JSON_UNQUOTE('"\\t\\u0032"');
> {code}
> Result:
> ||Heading 1||
> |2|
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to