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

Round-tripping RelNode via RelJson corrupts decimal literals

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.17.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      The SQL statement "VALUES 1.23" when parsed and converted into a RelNode is explained as "1:LogicalValues(tuples=[[\{ 1.23 }]])". So far so good.

       

      Then writing it out with a RelJsonWriter yields:

       

      {
      "rels": [
      {
      "id": "0",
      "relOp": "LogicalValues",
      "type": [
      {
      "type": "DECIMAL",
      "nullable": false,
      "precision": 3,
      "scale": 2,
      "name": "EXPR$0"
      }
      ],
      "tuples": [
      [
      123
      ]
      ],
      "inputs": []
      }
      ]
      }
      

        

      When it is read back in with a RelJsonReader, the new RelNode is explained as "2:LogicalValues(tuples=[[\{ 123 }]])" and the re-built SQL from RelToSqlConverter is: SELECT * FROM (VALUES (123)) AS "t" ("EXPR$0").

       

      I can't quite tell if the fault lies with the RelJsonWriter (for writing out "123") or the RelJsonReader (for not re-building the decimal using the "precision" and "scale" arguments).

       

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mprudhom Marc Prud'hommeaux
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: