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

Maksim Zhuravkov commented on CALCITE-5794:
-------------------------------------------

[~jhyde]
Thank you for the explanation. I looked this test case more thoroughly and it 
seems that `rowType` of `LogicalValues` correct:

{code:java}
RecordType(DECIMAL(4, 1) EXPR$0)
{code}

I think the issue is can be closed. Thanks again.


> Constant folding of CAST(literal AS decimal_type) ignores scale parameter of 
> a target type
> ------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-5794
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5794
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>
> Consider the following expression `CAST(100.00 AS DECIMAL(4,1))` it should 
> transform `100.00` to `100.0`. But constant folding optimization removes a 
> cast and the whole expression is replaced with `100.00` literal which is not 
> correct.
> *Reproducer*:
> {code:java}
> // SqlToRelConverterTest
>  @Test void testCastLiteralToDecimal() {
>     final String sql = "SELECT CAST(100.00 AS DECIMAL(4,1))";
>     sql(sql).ok();
>   }
> {code}
> Produces this plan:
> {code:java}
> LogicalValues(tuples=[[{ 100.00 }]])
> {code}
> *Expected behavior*: Cast is not removed/cast expression is replaced with 
> correct literal.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to