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

yongfu.gao commented on FLINK-41741:
------------------------------------

I reproduced the AssertionError with CEIL and FLOOR over a DECIMAL(2, 1) 
column. DecimalDataUtils.ceil and floor used the precision of the scaled 
BigDecimal instead of the input precision, while the inferred result type is 
DECIMAL(p, 0). I have a fix that preserves the input precision and an ITCase 
covering both functions: https://github.com/apache/flink/pull/30250

 

Could a committer please assign this issue to me (linkgoal)?

 

Release note: Fixes an AssertionError when CEIL or FLOOR is evaluated over a 
DECIMAL column when assertions are enabled; the result now preserves the 
declared DECIMAL precision.

> CEIL and FLOOR on a DECIMAL column fail with an AssertionError when 
> assertions are on
> -------------------------------------------------------------------------------------
>
>                 Key: FLINK-41741
>                 URL: https://issues.apache.org/jira/browse/FLINK-41741
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Runtime
>            Reporter: Martijn Visser
>            Priority: Major
>              Labels: pull-request-available
>
> DecimalDataUtils.ceil and floor return a DecimalData with the precision of 
> the BigDecimal, not the precision of the declared result type. 
> AbstractBinaryWriter.writeDecimal asserts value.precision() == precision, so 
> CEIL(d) over a multi-row VALUES of DECIMAL(2, 1) fails with an AssertionError 
> in the tests, which run with -ea. Without assertions the result is correct. 
> No test covers this: ExpressionTestBase casts results to VARCHAR before 
> writing them. FLINK-41726 describes the same kind of mismatch for the scale 
> of ROUND and TRUNCATE.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to