Skip to content

Commit

Permalink
fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
WangGuangxin committed Jan 20, 2025
1 parent 38a4fe7 commit 19936a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions velox/docs/functions/spark/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ JSON Functions
SELECT get_json_object('{"a"-3}'', '$.a'); -- NULL (malformed JSON string)
SELECT get_json_object('{"a":3}'', '.a'); -- NULL (malformed JSON path)

.. spark:function:: json_array_length(jsonString) -> integer
Returns the number of elements in the outermost JSON array from ``jsonString``.
If ``jsonString`` is not a valid JSON array or NULL, the function returns null. ::

SELECT json_array_length('[1,2,3,4]'); -- 4
SELECT json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]'); -- 5
SELECT json_array_length('[1,2'); -- NULL

.. spark:function:: json_object_keys(jsonString) -> array(string)
Returns all the keys of the outermost JSON object as an array if a valid JSON object is given.
Expand All @@ -44,12 +53,3 @@ JSON Functions
SELECT json_object_keys(''); -- NULL
SELECT json_object_keys(1); -- NULL
SELECT json_object_keys('"hello"'); -- NULL

.. spark:function:: json_array_length(jsonString) -> integer
Returns the number of elements in the outermost JSON array.
If jsonArray is not a valid JSON string or NULL, the function returns null. ::

SELECT json_array_length('[1,2,3,4]'); -- 4
SELECT json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]'); -- 5
SELECT json_array_length('[1,2'); -- NULL
4 changes: 2 additions & 2 deletions velox/functions/lib/JsonArrayLength.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace facebook::velox::functions {

/// json_array_length(jsonString) -> length
///
/// Returns the array length of json if a valid json string is given.
/// Returns null if the input json string is invalid.
/// Returns the number of elements in the outermost JSON array from jsonString.
/// If jsonString is not a valid JSON array or NULL, the function returns null.
/// Presto:
/// https://prestodb.io/docs/current/functions/json.html#json_array_length-json-bigint
/// SparkSQL:
Expand Down

0 comments on commit 19936a1

Please sign in to comment.