[ 
https://issues.apache.org/jira/browse/CALCITE-2810?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

xuqianjin updated CALCITE-2810:
-------------------------------
    Description: 
{{JSON_LENGTH(*json_doc*[, *path*])}}

Returns the length of a JSON document, or, if a _path_ argument is given, the 
length of the value within the document identified by the path. Returns 
{{NULL}} if any argument is {{NULL}} or the _path_ argument does not identify a 
value in the document. An error occurs if the _json_doc_ argument is not a 
valid JSON document or the _path_ argument is not a valid path expression or 
contains a {*} or {{}}*{{*}} wildcard.

The length of a document is determined as follows:
 * The length of a scalar is 1.

 * The length of an array is the number of array elements.

 * The length of an object is the number of object members.

 * The length does not count the length of nested arrays or objects.

Examples are as follows:

SELECT JSON_LENGTH('[1, 2, \\{"a": 3}]');
|                              3|

SELECT JSON_LENGTH('\{"a": 1, "b": {"c": 30}}');
|                                      2|

SELECT JSON_LENGTH('\{"a": 1, "b": {"c": 30}}', '$.b');
|                                             1|

  was:
{{JSON_LENGTH(*json_doc*[, *path*\])}}

Returns the length of a JSON document, or, if a _path_ argument is given, the 
length of the value within the document identified by the path. Returns 
{{NULL}} if any argument is {{NULL}} or the _path_ argument does not identify a 
value in the document. An error occurs if the _json_doc_ argument is not a 
valid JSON document or the _path_ argument is not a valid path expression or 
contains a {{*}} or {{**}} wildcard.

The length of a document is determined as follows:
 * The length of a scalar is 1.

 * The length of an array is the number of array elements.

 * The length of an object is the number of object members.

 * The length does not count the length of nested arrays or objects.

SELECT JSON_LENGTH('[1, 2, \{"a": 3}]');
+---------------------------------+
| JSON_LENGTH('[1, 2, \{"a": 3}]') |
+---------------------------------+
|                               3 |
+---------------------------------+
SELECT JSON_LENGTH('\{"a": 1, "b": {"c": 30}}');
+-----------------------------------------+
| JSON_LENGTH('\{"a": 1, "b": {"c": 30}}') |
+-----------------------------------------+
|                                       2 |
+-----------------------------------------+
SELECT JSON_LENGTH('\{"a": 1, "b": {"c": 30}}', '$.b');
+------------------------------------------------+
| JSON_LENGTH('\{"a": 1, "b": {"c": 30}}', '$.b') |
+------------------------------------------------+
|                                              1 |
+------------------------------------------------+


> Add the JSON_LENGTH function
> ----------------------------
>
>                 Key: CALCITE-2810
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2810
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: xuqianjin
>            Assignee: Julian Hyde
>            Priority: Major
>
> {{JSON_LENGTH(*json_doc*[, *path*])}}
> Returns the length of a JSON document, or, if a _path_ argument is given, the 
> length of the value within the document identified by the path. Returns 
> {{NULL}} if any argument is {{NULL}} or the _path_ argument does not identify 
> a value in the document. An error occurs if the _json_doc_ argument is not a 
> valid JSON document or the _path_ argument is not a valid path expression or 
> contains a {*} or {{}}*{{*}} wildcard.
> The length of a document is determined as follows:
>  * The length of a scalar is 1.
>  * The length of an array is the number of array elements.
>  * The length of an object is the number of object members.
>  * The length does not count the length of nested arrays or objects.
> Examples are as follows:
> SELECT JSON_LENGTH('[1, 2, \\{"a": 3}]');
> |                              3|
> SELECT JSON_LENGTH('\{"a": 1, "b": {"c": 30}}');
> |                                      2|
> SELECT JSON_LENGTH('\{"a": 1, "b": {"c": 30}}', '$.b');
> |                                             1|



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to