[ 
https://issues.apache.org/jira/browse/CALCITE-2808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16803014#comment-16803014
 ] 

Hongze Zhang commented on CALCITE-2808:
---------------------------------------

[~x1q1j1] - I've added some minor changes on top of your work, please kindly 
take a look: 
https://github.com/zhztheplayer/calcite/commits/XuQianJin-Stars-CALCITE-2808.

> Add the JSON_LENGTH function 
> -----------------------------
>
>                 Key: CALCITE-2808
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2808
>             Project: Calcite
>          Issue Type: Sub-task
>            Reporter: Forward Xu
>            Assignee: Forward Xu
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.20.0
>
>          Time Spent: 13h 10m
>  Remaining Estimate: 0h
>
> ```
>  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.
> Example Sql:
> {code:java}
> // code placeholder
> SELECT JSON_LENGTH(v) AS c1
> ,JSON_LENGTH(v, 'lax $.a') AS c2
> ,JSON_LENGTH(v, 'strict $.a[0]') AS c3
> ,JSON_LENGTH(v, 'strict $.a[1]') AS c4
> FROM (VALUES ('{"a": [10, true]}')) AS t(v)
> LIMIT 10;{code}
> Result:
> ||c1||c2||c3||c4||
> |1|2|1|1|
>  



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

Reply via email to