Martijn Visser created FLINK-34111:
--------------------------------------

             Summary: Add JSON_QUOTE and JSON_UNQUOTE function
                 Key: FLINK-34111
                 URL: https://issues.apache.org/jira/browse/FLINK-34111
             Project: Flink
          Issue Type: Sub-task
          Components: Table SQL / API
            Reporter: Martijn Visser


Escapes or unescapes a JSON string removing traces of offending characters that 
could prevent parsing.

Proposal:
- JSON_QUOTE: Quotes a string 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.
- JSON_UNQUOTE: Unquotes value and returns the result as a 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.

The following characters are reserved in JSON and must be properly escaped to 
be used in strings:

Backspace is replaced with \b
Form feed is replaced with \f
Newline is replaced with \n
Carriage return is replaced with \r
Tab is replaced with \t
Double quote is replaced with \"
Backslash is replaced with \\

This function exists in MySQL: 
- 
https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-quote
- 
https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-unquote

It's still open in Calcite CALCITE-3130



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

Reply via email to