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

CAST a literal to DECIMAL type return wrong result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.28.0
    • 1.38.0
    • None

    Description

      In calcite. The precision and scale can't work. 

      1) Add judgment in decimal type precision and scale parameter(When have illegal value need to throw an exception):

      SQL EXAMPLES:

      cast(155.36 as decimal(0,0))

      In Postgresql:

      ERROR: NUMERIC precision 0 must be between 1 and 1000

      In Calcite:

      EXPR$0=155.36

      2) To make sure return the right answer。

      SQL EXAMPLES:

      cast(155.36 as decimal(4,1))

      In Postgresql:

      EXPR$0=155.4

      In Calcite:

      EXPR$0=155.36

      The problem exists in casting different data to decimal.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m