XuQianJin-Stars opened a new pull request #1070: [CALCITE-2808]Add the 
JSON_LENGTH function
URL: https://github.com/apache/calcite/pull/1070
 
 
   ```
   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:
   
   ```sql
   SELECT JSON_LENGTH(v, 'lax $' ERROR ON ERROR) AS c1
   ,JSON_LENGTH(v, 'lax $.b' ERROR ON ERROR) AS c2
   ,JSON_LENGTH(v, 'strict $.a[0]' with wapper) AS c3
   ,JSON_LENGTH(v, 'strict $.a[1]' with wapper) AS c4
   FROM (VALUES ('{"a": [10, true],"b": "[10, true]"}')) AS t(v)
   limit 10;
   ```
   
   Result:
   
   | c1   | c2   | c3   | c4   |
   | ---- | ---- | ---- | ---- |
   | 2    | 1    | 1    | 1    |
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to