You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add SQL-compliant handling for json_merge() when arguments are null (#17983)
* Add SQL-compliant handling of json_merge() function with null expressions.
The json_merge() function fail with a query out with JSON_MERGE(null, null):
Function[json_merge] invalid input expected STRING but got STRING instead
The behavior in both mysql and postgres is that the function returns NULL
if any argument is NULL. This change adds that to align and make it SQL-compliant.
* One more doc change.
Copy file name to clipboardExpand all lines: docs/querying/sql-json-functions.md
+3-2
Original file line number
Diff line number
Diff line change
@@ -34,10 +34,11 @@ Druid supports nested columns, which provide optimized storage and indexes for n
34
34
35
35
You can use the following JSON functions to extract, transform, and create `COMPLEX<json>` objects.
36
36
37
+
37
38
| Function | Notes |
38
39
| --- | --- |
39
40
|`JSON_KEYS(expr, path)`| Returns an array of field names from `expr` at the specified `path`.|
40
-
|`JSON_MERGE(expr1, expr2[, expr3 ...])`| Merges two or more JSON `STRING` or `COMPLEX<json>` values into one, preserving the rightmost value when there are key overlaps. Always returns a `COMPLEX<json>` object.|
41
+
|`JSON_MERGE(expr1, expr2[, expr3 ...])`| Merges two or more JSON `STRING` or `COMPLEX<json>` values into one, preserving the rightmost value when there are key overlaps. Returns `NULL` if any argument is `NULL`. Always returns a `COMPLEX<json>` object.|
41
42
|`JSON_OBJECT(KEY expr1 VALUE expr2[, KEY expr3 VALUE 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. The following syntax is equivalent: `JSON_OBJECT(expr1:expr2[, expr3:expr4, ...])`.|
42
43
|`JSON_PATHS(expr)`| Returns an array of all paths which refer to literal values in `expr` in JSONPath format. |
43
44
|`JSON_QUERY(expr, path)`| Extracts a `COMPLEX<json>` value from `expr`, at the specified `path`. |
@@ -71,4 +72,4 @@ Consider the following example input JSON:
71
72
- For a key that contains an array, to return the entire array:<br />
72
73
`$['y']` -> `[1, 2, 3]`
73
74
- For a key that contains an array, to return an item in the array:<br />
0 commit comments