You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2019/06/16 18:50:00 UTC

[jira] [Commented] (CALCITE-3130) Implement JSON_UNQUOTE, JSON_QUOTE function

    [ https://issues.apache.org/jira/browse/CALCITE-3130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16865114#comment-16865114 ] 

Julian Hyde commented on CALCITE-3130:
--------------------------------------

I stopped reading when I saw you’d added a config parameter called “sql mode” and no useful description. Utterly meaningless to me, other Calcite users, and future maintainers. 

> 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
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> [{{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)