xiong duan created CALCITE-6478:
-----------------------------------

             Summary:  JSON functions should return NULL when input is NULL
                 Key: CALCITE-6478
                 URL: https://issues.apache.org/jira/browse/CALCITE-6478
             Project: Calcite
          Issue Type: Improvement
            Reporter: xiong duan


Here is the test in H2:
{code:java}
SELECT js,
       js IS JSON        "json?",
       js IS JSON value  "json?",
       js IS JSON SCALAR "scalar?",
       js IS JSON OBJECT "object?",
       js IS JSON ARRAY  "array?"
FROM (VALUES ('123'),
             ('"abc"'),
             ('{"a": "b"}'),
             ('[1,2]'),
             ('abc'), NULL) foo(js);
{code}
{code:java}
+----------+-----+-----+-------+-------+------+
|JS        |json?|json?|scalar?|object?|array?|
+----------+-----+-----+-------+-------+------+
|123       |true |true |true   |false  |false |
|"abc"     |true |true |true   |false  |false |
|{"a": "b"}|true |true |false  |true   |false |
|[1,2]     |true |true |false  |false  |true  |
|abc       |false|false|false  |false  |false |
|null      |null |null |null   |null   |null  |
+----------+-----+-----+-------+-------+------+
{code}
Same SQL in Calcite:
{code:java}
+------------+-------+-------+---------+---------+--------+
| JS         | json? | json? | scalar? | object? | array? |
+------------+-------+-------+---------+---------+--------+
| "abc"      | true  | true  | true    | false   | false  |
| 123        | true  | true  | true    | false   | false  |
| [1,2]      | true  | true  | false   | false   | true   |
| abc        | false | false | false   | false   | false  |
| {"a": "b"} | true  | true  | false   | true    | false  |
|            | false | false | false   | false   | false  |
+------------+-------+-------+---------+---------+--------+
{code}





--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to