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

Druid adapter uses un-scaled value of DECIMAL literals

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.12.0
    • Fix Version/s: 1.13.0
    • Component/s: None
    • Labels:
      None

      Description

      We have 2 issue here:
      1 Major, it is the lose of precision when converting filters with double values eg

       value < 1.455 

      For instance this is an example of wrong plan due to this bug.

       
       explain select d_year from ssb_druid where cast(d_year as double) < 1.2221;
      OK
      Plan optimized by CBO.
      
      Stage-0
        Fetch Operator
          limit:-1
          Select Operator [SEL_1]
            Output:["_col0"]
            TableScan [TS_0]
              Output:["d_year"],properties:{"druid.query.json":"{\"queryType\":\"select\",\"dataSource\":\"ssb_druid\",\"descending\":false,\"intervals\":[\"1900-01-01T00:00:00.000/3000-01-01T00:00:00.000\"],\"filter\":{\"type\":\"bound\",\"dimension\":\"d_year\",\"upper\":\"12221\",\"upperStrict\":true,\"alphaNumeric\":true},\"dimensions\":[\"d_year\"],\"metrics\":[],\"granularity\":\"all\",\"pagingSpec\":{\"threshold\":16384,\"fromNext\":true},\"context\":{\"druid.query.fetch\":false}}","druid.query.type":"select"}
      

      The second issue (Minor) is to use

      ordering

      instead of Alphanumeric, this is needed when comparing floats/doubles.

        Issue Links

          Activity

          Show
          bslim slim bouguerra added a comment - https://github.com/apache/calcite/pull/411
          Hide
          julianhyde Julian Hyde added a comment -

          Does this change pass the test suite and verify?

          Are the numerous other places that call RexLiteral.getValue2 affected by this change?

          Show
          julianhyde Julian Hyde added a comment - Does this change pass the test suite and verify? Are the numerous other places that call RexLiteral.getValue2 affected by this change?
          Hide
          bslim slim bouguerra added a comment -

          Julian Hyde pointed out that what we need is getValue3 that returns the Bigdecimal as is.

          Show
          bslim slim bouguerra added a comment - Julian Hyde pointed out that what we need is getValue3 that returns the Bigdecimal as is.
          Hide
          jcamachorodriguez Jesus Camacho Rodriguez added a comment -

          slim bouguerra, looks good. Could you confirm if we need to move to 0.9.2 before the _ alphaNumeric_ change goes in?

          If so, we could split this into two different issues...

          Show
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - slim bouguerra , looks good. Could you confirm if we need to move to 0.9.2 before the _ alphaNumeric_ change goes in? If so, we could split this into two different issues...
          Hide
          jcamachorodriguez Jesus Camacho Rodriguez added a comment -

          I have fixed the un-scaled problem in http://git-wip-us.apache.org/repos/asf/calcite/commit/370dfda.

          I have created CALCITE-1724 to tackle the ordering issue when we move to 0.9.2.

          Thanks slim bouguerra!

          Show
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - I have fixed the un-scaled problem in http://git-wip-us.apache.org/repos/asf/calcite/commit/370dfda . I have created CALCITE-1724 to tackle the ordering issue when we move to 0.9.2. Thanks slim bouguerra !
          Hide
          jcamachorodriguez Jesus Camacho Rodriguez added a comment -

          Resolved in release 1.13.0 (2017-06-26).

          Show
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.13.0 (2017-06-26).

            People

            • Assignee:
              bslim slim bouguerra
              Reporter:
              bslim slim bouguerra
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development