Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-524

Drill returns float for MOD function that contains decimal number & divident not returned if divider is 0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0.0
    • 0.4.0
    • Functions - Drill
    • None

    Description

      Ran the following mod function in drill:
      0: jdbc:drill:schema=dfs> select mod(12.4,5) from dfs.`voter` where rownum=10;
      ------------

      EXPR$0

      ------------

      2.4000000000000004

      ------------

      The result is a float which looks messy. The other db platforms return result based on the highest number of significant digits either from the divident or divider. For example from oracle:
      SQL> select mod(12.4,5) from voter where voter_id=10;

      MOD(12.4,5)
      -----------
      2.4

      SQL> select mod(12.45,5.1) from voter where voter_id=10;

      MOD(12.45,5.1)
      --------------
      2.25

      Another issue is when the divider is 0. Here is the spec for MOD from http://users.atw.hu/sqlnut/sqlnut2-chp-4-sect-4.html

      ...returns the dividend if the divider is 0

      Drill returns "NaN" if the divider is 0:
      0: jdbc:drill:schema=dfs> select mod(age,0) from dfs.`voter` where rownum=11;
      ------------

      EXPR$0

      ------------

      NaN

      ------------

      Based on postgres, mysql and oracle databases, only oracle adheres to this rule:
      SQL> select mod(12.45,0) from voter where voter_id=10;

      MOD(12.45,0)
      ------------
      12.45

      Attachments

        Activity

          People

            DrillCommitter DrillCommitter
            knguyen Krystal
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: