Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6478

JSON functions should return NULL when input is NULL

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.38.0
    • None

    Description

      Here is the test in H2:

      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);
      
      +----------+-----+-----+-------+-------+------+
      |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  |
      +----------+-----+-----+-------+-------+------+
      

      Same SQL in Calcite:

      +------------+-------+-------+---------+---------+--------+
      | 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  |
      +------------+-------+-------+---------+---------+--------+
      

      Attachments

        Issue Links

          Activity

            People

              nobigo xiong duan
              nobigo xiong duan
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: