[
https://issues.apache.org/jira/browse/CALCITE-5794?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Julian Hyde resolved CALCITE-5794.
----------------------------------
Fix Version/s: 1.35.0
Resolution: Not A Problem
> 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
> Fix For: 1.35.0
>
>
> 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)