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

Hongze Zhang edited comment on CALCITE-2791 at 2/19/19 5:14 AM:
----------------------------------------------------------------

[~x1q1j1], Did you intent to use values('{"a": [10, true]}')? The picture you 
putĀ above shows what you tested is values('{"a": "[10, true]"}').
 You can use strict syntax of JSON_VALUE to see the error message. E.g.
{code:java}
SELECT JSON_VALUE(v, 'strict $.a[0]' ERROR ON ERROR)
FROM (VALUES ('{"a": "[10, true]"}')) AS t(v);
{code}
It will give you something like
{code:java}
Filter: [0] can only be applied to arrays. Current context is: [10, true]
{code}


was (Author: zhztheplayer):
[~x1q1j1], Did you intent to include to use values('\{"a": [10, true]}')? The 
picture you putĀ above shows what you tested is values('\{"a": "[10, true]"}').
 You can use strict syntax of JSON_VALUE to see the error message. E.g.
{code:java}
SELECT JSON_VALUE(v, 'strict $.a[0]' ERROR ON ERROR)
FROM (VALUES ('{"a": "[10, true]"}')) AS t(v);
{code}
It will give you something like
{code:java}
Filter: [0] can only be applied to arrays. Current context is: [10, true]
{code}

> Add the JSON_TYPE function
> --------------------------
>
>                 Key: CALCITE-2791
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2791
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Forward Xu
>            Assignee: Julian Hyde
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: image-2019-02-19-12-24-10-200.png
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The data in json can be =, <, <=, >, >=, <>,! =, and <=>. But the data types 
> in json can be diverse, so when you compare different types, you have a 
> priority, and the high priority is greater than the low priority (you can 
> view the types with the JSON_TYPE() function). The priorities are as follows:
>  BOOLEAN,ARRAY,OBJECT,STRING,INTEGE,DOUBLE,NULL
> Example Data:
> {"a":[10,true]}
> SELECT JSON_TYPE(v) AS c1,
> JSON_TYPE(a) AS c2,
> JSON_TYPE(b) AS c3,
> JSON_TYPE(c) AS c4 FROM (VALUES ('\{"a": [10, true]}','[10, true]', '10', 
> 'true')) AS t(v, a, b, c) 
> limit 10;
> c1 c2 c3 c4
>  ======= ======= ======= =======
>  OBJECT ARRAY INTEGER BOOLEAN



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

Reply via email to