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

Explicit cast to numeric type doesn't check overflow

    XMLWordPrintableJSON

Details

    Description

      Explicit cast to numeric type doesn't check overflow, and this issue can be reproduced by sqlline:

      select cast(empno as tinyint), cast(130 as tinyint) from emps where name='Alice'; -- empno is 130
      

      The empno is INT type. The result is wrong:

      -126, -126

      I think it should throw exception when overflow, instead of returning wrong result to user.
      At last, this issue was found when to turn on runtime check for CalciteSqlOperatorTest in CALCITE-5921.

      Attachments

        Issue Links

          Activity

            People

              mbudiu Mihai Budiu
              Runking Runkang He
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: