You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2018/05/02 05:15:00 UTC
[jira] [Created] (DRILL-6376) Doc: Return type of ROUND(x, y),
TRUNC(x, y), TO_NUMBER is wrong
Paul Rogers created DRILL-6376:
----------------------------------
Summary: Doc: Return type of ROUND(x, y), TRUNC(x, y), TO_NUMBER is wrong
Key: DRILL-6376
URL: https://issues.apache.org/jira/browse/DRILL-6376
Project: Apache Drill
Issue Type: Bug
Affects Versions: 1.13.0
Reporter: Paul Rogers
Assignee: Bridget Bevens
The documentation for [math functions|http://drill.apache.org/docs/math-and-trig/] claims that the return value of {{ROUND(x, y)}} and {{TRUNC(x, y)}} is {{DECIMAL}}. A test shows that this is not true:
{noformat}
SELECT typeof(ROUND(a, 2)) FROM (VALUES (1.2345)) AS T(a);
+---------+
| EXPR$0 |
+---------+
| FLOAT8 |
+---------+
SELECT typeof(TRUNC(a, 2)) FROM (VALUES (1.2345)) AS T(a);
+---------+
| EXPR$0 |
+---------+
| FLOAT8 |
+---------+
{noformat}
Maybe it is {{DECIMAL}} only if we enable decimal type? Let's try:
{noformat}
ALTER SESSION SET `planner.enable_decimal_data_type` = true;
SELECT typeof(TRUNC(a, 2)) FROM (VALUES (1.2345)) AS T(a);
+---------+
| EXPR$0 |
+---------+
| FLOAT8 |
+---------+
{noformat}
So, {{ROUND()}} and {{TRUNC()}} actually return {{DOUBLE}}.
The [type convertion|http://drill.apache.org/docs/data-type-conversion/] documentation says that {{TO_NUMBER(str, fmt)}} returns {{DECIMAL}}. Let's try:
{noformat}
ALTER SESSION SET `planner.enable_decimal_data_type` = true;
SELECT typeof(TO_NUMBER(a, '0')) FROM (VALUES ('1')) AS T(a);
+---------+
| EXPR$0 |
+---------+
| FLOAT8 |
+---------+
{noformat}
So, {{TO_NUMBER()}} actually returns {{DOUBLE}}.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)