You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/04/28 05:29:00 UTC

[jira] [Commented] (IMPALA-6518) Fix the output type of a decimal union for decimal_v2

    [ https://issues.apache.org/jira/browse/IMPALA-6518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16457367#comment-16457367 ] 

ASF subversion and git services commented on IMPALA-6518:
---------------------------------------------------------

Commit d0f838b66a935310de9aeae7b9ba6513a5197ba9 in impala's branch refs/heads/master from [~tarasbob]
[ https://git-wip-us.apache.org/repos/asf?p=impala.git;h=d0f838b ]

IMPALA-6340,IMPALA-6518: Check that decimal types are compatible in FE

In this patch we implement strict decimal type checking in the FE in
various situations when DECIMAL_V2 is enabled. What is affected:
- Union. If we union two decimals and it is not possible to come up
  with a decimal that will be able to contain all the digits, an error
  is thrown. For example, the union(decimal(20, 10), decimal(20, 20))
  returns decimal(30, 20). However, for union(decimal(38, 0),
  decimal(38, 38)) the ideal return type would be decimal(76,38), but
  this is too large, so an error is thrown.
- Insert. If we are inserting a decimal value into a column where we are
  not guaranteed that all digits will fit, an error is thrown. For
  example, inserting a decimal(38,0) value into a decimal(38,38) column.
- Functions such as coalesce(). If we are unable to determine the output
  type that guarantees that all digits will fit from all the arguments,
  an error is thrown. For example,
  coalesce(decimal(38,38), decimal(38,0)) will throw an error.
- Hash Join. When joining on two decimals, if a type cannot be
  determined that both columns can be cast to, we throw an error.
  For example, join on decimal(38,0) and decimal(38,38) will result
  in an error.

To avoid these errors, you need to use CAST() on some of the decimals.

In this patch we also change the output decimal calculation of decimal
round, truncate and related functions. If these functions are a no-op,
the resulting decimal type is the same as the input type.

Testing:
- Ran a core build which passed.

Change-Id: Id406f4189e01a909152985fabd5cca7a1527a568
Reviewed-on: http://gerrit.cloudera.org:8080/9930
Reviewed-by: Alex Behm <al...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


> Fix the output type of a decimal union for decimal_v2
> -----------------------------------------------------
>
>                 Key: IMPALA-6518
>                 URL: https://issues.apache.org/jira/browse/IMPALA-6518
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Frontend
>    Affects Versions: Impala 3.0
>            Reporter: Taras Bobrovytsky
>            Assignee: Taras Bobrovytsky
>            Priority: Major
>
> In the following query, the type of c1 is decimal(38, 38) for both decimal v1 and v2.
> {code:java}
> select c1 from (
> select cast(1 as decimal(38, 0)) as c1
> union all
> select cast(0.1 as decimal(38, 38)) as c1) t{code}
> This means that we are truncating from the front. It would make more sense to truncate from the back and round when decimal v2 is enabled. The output type should be (38, 6). This is what we do for other mathematical operations, such as addition.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org