Airblader commented on a change in pull request #17275:
URL: https://github.com/apache/flink/pull/17275#discussion_r707981169



##########
File path: docs/data/sql_functions.yml
##########
@@ -687,6 +690,10 @@ json:
       JSON_QUERY('[1, 2]', '$')
       -- NULL
       JSON_QUERY(CAST(NULL AS STRING), '$')
+      -- [30, 40]

Review comment:
       I think one example for `*` would be enough, and again it would be nice 
to make the example simple so it focuses on what we actually want to 
demonstrate.
   
   Also, the comment showing the result should indicate the proper type, i.e. 
put quotes around it to signify that it returns a string and not an array:
   
   ```
   -- '[1, 2, 3]'
   JSON_QUERY('{"a": [1, 2, 3]}', 'lax $.a[*]')
   ```

##########
File path: docs/data/sql_functions.yml
##########
@@ -665,6 +665,9 @@ json:
       // STRING: "false"
       JSON_VALUE('{"a": true}', 'strict $.b'
           DEFAULT FALSE ON ERROR)
+
+      // DOUBLE: 0.998

Review comment:
       Could you maybe turn all of the `//` for the examples of this function 
into `--`? The double slashes are actually incorrect for SQL, so we should fix 
this in a separate commit.

##########
File path: docs/data/sql_functions.yml
##########
@@ -665,6 +665,9 @@ json:
       // STRING: "false"
       JSON_VALUE('{"a": true}', 'strict $.b'
           DEFAULT FALSE ON ERROR)
+
+      // DOUBLE: 0.998
+      JSON_VALUE('{"a": {"b.c": [0.998,0.996]}}','$.a.[''b.c''][0]' RETURNING 
DOUBLE)

Review comment:
       Since FLINK-24271 is about adding an example on how to access keys with 
"non-trivial" names, how about keeping the example as simple as possible to 
focus on actually showing how to do that? For example, like this:
   
   ```
   // INT: 1
   JSON_VALUE('{"a.b": 1}', '$.[''a.b'']' RETURNING INT)
   ```
   
   Please also run the docs locally and make sure that the line length of the 
example doesn't cause the code block to scroll. If it does, line-break the 
example (as I did in the examples above) to prevent it from scrolling.

##########
File path: docs/data/sql_functions.yml
##########
@@ -665,6 +665,9 @@ json:
       // STRING: "false"
       JSON_VALUE('{"a": true}', 'strict $.b'
           DEFAULT FALSE ON ERROR)
+
+      // DOUBLE: 0.998
+      JSON_VALUE('{"a": {"b.c": [0.998,0.996]}}','$.a.[''b.c''][0]' RETURNING 
DOUBLE)

Review comment:
       For what it's worth, there is nothing special about this in terms of 
JSON functions. This is just a case of escaping a single quote within a SQL 
string.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to