[ 
https://issues.apache.org/jira/browse/FLINK-22586?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Shuo Cheng updated FLINK-22586:
-------------------------------
    Description: 
Currently the precision and scale derivation is not properly for decimal data 
arithmetics, e.g,

considering the following example:
{code:java}
select cast('10.1' as decimal(38, 19)) * cast('10.2' as decimal(38, 19)) from 
T{code}
the result is `null`, which may confuses use a lot, because the result is 
actually not that big.

The root cause is the precision derivation for the above multiplication is:

(38, 19) * (38, 19) -> (38, 38)

So there is no space for integral digits, which leads to null results. 

  was:
Currently the precision and scale derivation is not properly for decimal data 
arithmetics, e.g,

considering the following example:
{code:java}
select cast('10.1' as decimal(38, 19)) * cast('10.2' as decimal(38, 19)) from 
T{code}
the result is `null`, which may confuses use a lot, because the result is far 
from overflow actually. 

The root cause is the precision derivation for the above multiplication is:

(38, 19) * (38, 19) -> (38, 38)

So there is no space for integral digits, which leads to null results. 


> Improve precision derivation for decimal arithmetics
> ----------------------------------------------------
>
>                 Key: FLINK-22586
>                 URL: https://issues.apache.org/jira/browse/FLINK-22586
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / Runtime
>    Affects Versions: 1.13.0
>            Reporter: Shuo Cheng
>            Priority: Major
>             Fix For: 1.14.0
>
>
> Currently the precision and scale derivation is not properly for decimal data 
> arithmetics, e.g,
> considering the following example:
> {code:java}
> select cast('10.1' as decimal(38, 19)) * cast('10.2' as decimal(38, 19)) from 
> T{code}
> the result is `null`, which may confuses use a lot, because the result is 
> actually not that big.
> The root cause is the precision derivation for the above multiplication is:
> (38, 19) * (38, 19) -> (38, 38)
> So there is no space for integral digits, which leads to null results. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to