Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-1879

mod() function doesn't always interpret fractional arguments as DECIMAL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • Impala 2.2
    • None
    • Frontend

    Description

      In constructing examples for the mod() function, I noticed that with some combinations of arguments the DECIMAL overload was not chosen, leading to rounding errors:

      select mod(9.9,3);
      +--------------------+
      | mod(9.9, 3)        |
      +--------------------+
      | 0.8999996185302734 |
      +--------------------+
      

      If I use a cast or a more obviously DECIMAL literal for the second argument, I get the expected result:

      select mod(9.9, cast(3 as decimal(2,1)));
      +-----------------------------------+
      | mod(9.9, cast(3 as decimal(2,1))) |
      +-----------------------------------+
      | 0.9                               |
      +-----------------------------------+
      
      select mod(9.9,3.0);
      +---------------+
      | mod(9.9, 3.0) |
      +---------------+
      | 0.9           |
      +---------------+
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jrussell John Russell
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: