You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ritesh (JIRA)" <ji...@apache.org> on 2019/02/28 06:58:00 UTC
[jira] [Updated] (CALCITE-2880) Add the JSON_PRETTY function
[ https://issues.apache.org/jira/browse/CALCITE-2880?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ritesh updated CALCITE-2880:
----------------------------
Description:
```
JSON_PRETTY(**json_string_doc**)
```
Returns the pretty formatted JSON document. Returns `NULL` if any argument is `NULL` or if JSON document is invalid.
Example Sql:
```sql
SELECT JSON_PRETTY(v) AS c1
FROM (VALUES ('\{"a": [10, true],"b": [10, true]}')) as t(v)
limit 10
```
Result:
|c1|
|----|
|{
"a" : [ 10, true ],
"b" : [ 10, true ]
}|
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.
Example Sql:
```sql
SELECT JSON_LENGTH(v, 'lax $' ERROR ON ERROR) AS c1
,JSON_LENGTH(v, 'lax $.a' ERROR ON ERROR) AS c2
,JSON_LENGTH(v, 'strict $.a[0]' ERROR ON ERROR) AS c3
,JSON_LENGTH(v, 'strict $.a[1]' ERROR ON ERROR) AS c4
FROM (VALUES ('\{"a": [10, true]}')) AS t(v)
limit 10;
```
Result:
| c1 | c2 | c3 | c4 |
| ---- | ---- | ---- | ---- |
| 1 | 2 | 1 | 1 |
> Add the JSON_PRETTY function
> -----------------------------
>
> Key: CALCITE-2880
> URL: https://issues.apache.org/jira/browse/CALCITE-2880
> Project: Calcite
> Issue Type: Sub-task
> Reporter: Ritesh
> Assignee: Forward Xu
> Priority: Major
> Labels: pull-request-available
>
> ```
> JSON_PRETTY(**json_string_doc**)
> ```
> Returns the pretty formatted JSON document. Returns `NULL` if any argument is `NULL` or if JSON document is invalid.
> Example Sql:
> ```sql
> SELECT JSON_PRETTY(v) AS c1
> FROM (VALUES ('\{"a": [10, true],"b": [10, true]}')) as t(v)
> limit 10
> ```
> Result:
> |c1|
> |----|
> |{
> "a" : [ 10, true ],
> "b" : [ 10, true ]
> }|
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)