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

ASF GitHub Bot updated CALCITE-5843:
------------------------------------
    Labels: pull-request-available  (was: )

> Legal constant SQL expression with cast causes a parse error
> ------------------------------------------------------------
>
>                 Key: CALCITE-5843
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5843
>             Project: Calcite
>          Issue Type: Bug
>          Components: linq4j
>    Affects Versions: 1.34.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>              Labels: pull-request-available
>
> This program fails at compilation time:
> {code:sql}
> SELECT CAST(CAST('32767.4' AS FLOAT) AS SMALLINT)
> {code}
> This happens in linq4j in Expressions.constant:
> {code:java}
> if ((clazz != Float.class && clazz != Double.class || !(value instanceof 
> BigDecimal)) && !clazz.isInstance(value)) {
>                 String stringValue = String.valueOf(value);
>                 if (type == BigDecimal.class) {
>                     value = new BigDecimal(stringValue);
>                 }
>                 if (type == BigInteger.class) {
>                     value = new BigInteger(stringValue);
>                 }
>                 if (primitive != null) {
>                     value = primitive.parse(stringValue);  // << error 
> happens here
>                 }
>             }
> {code}



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

Reply via email to