Skip to content

Commit

Permalink
[FLINK-29096][table] Update documentation for JSON_VALUE special char…
Browse files Browse the repository at this point in the history
…acters
  • Loading branch information
wuchong committed Aug 26, 2022
1 parent 60e5944 commit 3149c62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions docs/data/sql_functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,10 @@ json:
expression. If the default value itself raises an error, it falls through to the error
behavior for `ON EMPTY`, and raises an error for `ON ERROR`.
For path contains blank characters, should use '[]', which is the grammar of json-path.
And path is literal, the character `'` already exists. So you should also use sql escape characters `'`.
For path contains special characters such as spaces, you can use `['property']` or `["property"]`
to select the specified property in a parent object. Be sure to put single or double quotes around the property name.
When using JSON_VALUE in SQL, the path is a character parameter which is already single quoted,
so you have to escape the single quotes around property name, such as `JSON_VALUE('{"a b": "true"}', '$.[''a b'']')`.
```
-- "true"
Expand Down
5 changes: 3 additions & 2 deletions docs/data/sql_functions_zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,9 @@ json:
对于空路径表达式或错误,可以将行为定义为返回 `null`、引发错误或返回定义的默认值。当省略时,默认为 `NULL ON EMPTY` 或
`NULL ON ERROR`。默认值可以是文字或表达式。如果默认值本身引发错误,通过错误就会造成 `ON EMPTY` 的行为,并引发 `ON ERROR` 的错误。
对于路径表达式中包含空格时,需要使用 '[]', 该语法来自于json-path.同时,path是个常量已经有 `'`字符,因此还需要增加sql转义字符.
对于路径表达式中包含特殊字符(如空格),你可以使用`['property']` 获 `["property"]`来引用父对象中指定的属性。请确保在属性名两侧加上单引号或双引号。
当在 SQL 使用 JSON_VALUE 时,路径作为一个字符串参数已经被单引号引用了,因此你必须将属性名上的单引号转义,如`JSON_VALUE('{"a b": "true"}', '$.[''a b'']')`。

```
-- "true"
Expand Down

0 comments on commit 3149c62

Please sign in to comment.