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

pmod() sometimes returns negative values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Won't Fix
    • Impala 2.2
    • None
    • Backend

    Description

      I noticed when constructing examples to compare/contrast fmod(), pmod(), and the new mod() function that pmod() sometimes returns a negative value, despite its being stated to be the "positive" modulus:

      [localhost:21000] > select pmod(5,-2);
      +-------------+
      | pmod(5, -2) |
      +-------------+
      | -1          |
      +-------------+
      

      I see that's the same return value as Hive:

      hive> select pmod(5,-2) from t1 limit 1;
      Total MapReduce jobs = 1
      ...
      OK
      -1
      Time taken: 29.269 seconds
      

      This seems to be the origin of the Hive pmod() function, it isn't spec'ed out in detail: https://issues.apache.org/jira/browse/HIVE-656

      I thought we should verify that our behavior is working as intended, and if so let's firm up the explanation of the function a big. ("Returns the positive modulus except if second argument negative", or something like that.)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: