Skip to content

Commit

Permalink
Revise document
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Mar 6, 2024
1 parent 1b56b1e commit 11bc81c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions velox/docs/functions/spark/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ JSON Functions
.. spark:function:: get_json_object(jsonString, path) -> varchar
Returns a json object, represented by VARCHAR, from ``jsonString`` by searching ``path``.
Valid ``path`` should contain "[index]", "[field]" or ".field" to define a JSON path.
Here are some examples: "$.a" "$.a.b", "$[0][a].b". Returns NULL if it finds json string
is malformed or ``path`` doesn't exist. ::
Valid ``path`` should start with '$' and then contain "[index]", "[field]" or ".field"
to define a JSON path. Here are some examples: "$.a" "$.a.b", "$[0][a].b". Returns NULL if
``jsonString`` or ``path`` is malformed. Also returns NULL if ``path`` doesn't exist. ::

SELECT get_json_object('{"a":"b"}', '$.a'); -- 'b'
SELECT get_json_object('{"a":{"b":"c"}}', '$.a'); -- '{"b":"c"}'
SELECT get_json_object('{"a": "3"}', '$.b'; -- NULL (not found field)
SELECT get_json_object('{"a"-3}'', $.a); -- NULL (malformed JSON string)
SELECT get_json_object('{"a":3}', '$.b'); -- NULL (not found field)
SELECT get_json_object('{"a"-3}'', '$.a'); -- NULL (malformed JSON string)
SELECT get_json_object('{"a":3}'', '.a'); -- NULL (malformed JSON path)
2 changes: 1 addition & 1 deletion velox/functions/sparksql/SIMDJsonFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct SIMDGetJsonObjectFunction {
}

private:
// Makes a conversion from spark's json path to json pointer, e.g., converts
// Makes a conversion from Spark's json path to json pointer, e.g., converts
// "$.a.b" to "/a/b".
// See simdjson link:
// https://github.com/simdjson/simdjson/blob/master/doc/dom.md#json-pointer
Expand Down

0 comments on commit 11bc81c

Please sign in to comment.