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

Incorrect precision derivation for negative numeric types

    XMLWordPrintableJSON

Details

    Description

      Test highlights the problem :

        @Test void testTypeOfAs() {
          sql("select DECIMAL '100.01' as c1 from (values (true))")
              .columnType("DECIMAL(5, 2) NOT NULL");
          sql("select DECIMAL '-100.01' as c1 from (values (true))")
              .columnType("DECIMAL(5, 2) NOT NULL");
      }
      

      Throws exception for second expression:

      Expected: is "DECIMAL(5, 2) NOT NULL"
           but: was "DECIMAL(6, 2) NOT NULL"
      

      Seems root cause in SqlLiteral#createExactNumeric precision derivation not consider negative numbers.

      Attachments

        Issue Links

          Activity

            People

              mbudiu Mihai Budiu
              zstan Evgeny Stanilovsky
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: