Mihai Budiu created CALCITE-5843:
------------------------------------

             Summary: Legal SQL expression 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


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