writer-jill commented on code in PR #17635:
URL: https://github.com/apache/druid/pull/17635#discussion_r1932298072


##########
docs/querying/sql-functions.md:
##########
@@ -2787,70 +2787,222 @@ Returns the following:
 
 ## JSON_KEYS
 
-Returns an array of field names from `expr` at the specified `path`.
+Returns an array of field names from an expression, at a specified path.
 
-* **Syntax**: `JSON_KEYS(expr, path)`
+* **Syntax:** `JSON_KEYS(expr, path)`
 * **Function type:** JSON
 
-[Learn more](sql-json-functions.md)
+<details><summary>Example</summary>
+
+The following example returns an array of field names from the nested column 
`agent`:
+
+```sql
+SELECT
+  JSON_KEYS(agent, '$.') AS agent_keys
+FROM "kttm_nested"
+LIMIT 1
+```
+
+Returns the following:
 
+| `agent_keys` |
+| -- |
+| `[type, category, browser, browser_version, os, platform]` |
+
+</details>
+
+[Learn more](sql-json-functions.md)
 
 ## JSON_MERGE
 
-Merges two or more JSON `STRING` or `COMPLEX<json>` into one. Preserves the 
rightmost value when there are key overlaps. Returning always a `COMPLEX<json>` 
type.
+Merges two or more JSON `STRING` or `COMPLEX<json>` expressions into one, 
preserving the rightmost value when there are key overlaps.
+The function always returns a `COMPLEX<json>` object.
 
 * **Syntax:** `JSON_MERGE(expr1, expr2[, expr3 ...])`
 * **Function type:** JSON
 
-[Learn more](sql-json-functions.md)
+<details><summary>Example</summary>
+
+The following example merges the `event` object with a static string 
`example_string`:
+
+```sql
+SELECT 
+  event,
+  JSON_MERGE(event, '{"example_string": 123}') as eventAndstring
+FROM "kttm_nested"
+LIMIT 1
+```
+
+Returns the following:
 
+| `event` | `eventAndstring` |
+| -- | -- |
+| `{"type":"PercentClear","percentage":55}` | 
`{"type":"PercentClear","percentage":55,"example_string":123}` |
+
+</details>
+
+[Learn more](sql-json-functions.md)
 
 ## JSON_OBJECT
 
-Constructs a new `COMPLEX<json>` object. The `KEY` expressions must evaluate 
to string types. The `VALUE` expressions can be composed of any input type, 
including other `COMPLEX<json>` values. `JSON_OBJECT` can accept 
colon-separated key-value pairs. The following syntax is equivalent: 
`JSON_OBJECT(expr1:expr2[, expr3:expr4, ...])`.
+Constructs a new `COMPLEX<json>` object from one or more expressions. 
+The `KEY` expressions must evaluate to string types.
+The `VALUE` expressions can be composed of any input type, including other 
`COMPLEX<json>` objects.
+The function can accept colon-separated key-value pairs.
 
-* **Syntax**: `JSON_OBJECT(KEY expr1 VALUE expr2[, KEY expr3 VALUE expr4, 
...])`
+* **Syntax:** `JSON_OBJECT(KEY expr1 VALUE expr2[, KEY expr3 VALUE expr4, 
...])`  
+  or  
+  `JSON_OBJECT(expr1:expr2[, expr3:expr4, ...])`
 * **Function type:** JSON
 
-[Learn more](sql-json-functions.md)
+<details><summary>Example</summary>
+
+The following example creates a new object `combinedJSON` from `continent` in 
`geo_ip` and `type` in `event`:
+
+```sql
+SELECT
+  JSON_OBJECT(
+     KEY 'geo_ip' VALUE JSON_QUERY(geo_ip, '$.continent'),
+     KEY 'event' VALUE JSON_QUERY(event, '$.type')
+     )
+  as combinedJSON

Review Comment:
   updated



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to