Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.13.0
-
None
-
None
Description
The documentation for math functions claims that the return value of ROUND(x, y) and TRUNC(x, y) is DECIMAL. A test shows that this is not true:
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 | +---------+
Maybe it is DECIMAL only if we enable decimal type? Let's try:
ALTER SESSION SET `planner.enable_decimal_data_type` = true; SELECT typeof(TRUNC(a, 2)) FROM (VALUES (1.2345)) AS T(a); +---------+ | EXPR$0 | +---------+ | FLOAT8 | +---------+
So, ROUND() and TRUNC() actually return DOUBLE.
The type convertion documentation says that TO_NUMBER(str, fmt) returns DECIMAL. Let's try:
ALTER SESSION SET `planner.enable_decimal_data_type` = true; SELECT typeof(TO_NUMBER(a, '0')) FROM (VALUES ('1')) AS T(a); +---------+ | EXPR$0 | +---------+ | FLOAT8 | +---------+
So, TO_NUMBER() actually returns DOUBLE.