Krystal created DRILL-524:
-----------------------------
Summary: Drill returns float for MOD function that contains
decimal number & divident not returned if divider is 0
Key: DRILL-524
URL: https://issues.apache.org/jira/browse/DRILL-524
Project: Apache Drill
Issue Type: Bug
Affects Versions: 1.0.0
Reporter: Krystal
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
--
This message was sent by Atlassian JIRA
(v6.2#6252)