Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-6265] Type coercion is failing for numeric values in prepared statements #3687

Merged
merged 1 commit into from
Apr 8, 2024

Commits on Mar 7, 2024

  1. [CALCITE-6265] Type coercion is failing for numeric values in prepare…

    …d statements
    
    Given a column of type `INT`. When providing a `short` value as a
    placeholder in a prepared statement, a `ClassCastException` is thrown.
    
    Test case:
    ```
    final String sql =
        "select \"empid\" from \"hr\".\"emps\" where \"empid\" in (?, ?)";
    CalciteAssert.hr()
        .query(sql)
        .consumesPreparedStatement(p -> {
            p.setShort(1, (short) 100);
            p.setShort(2, (short) 110);
        })
        .returnsUnordered("empid=100", "empid=110");
    ```
    
    Stack trace:
    ```
    java.lang.ClassCastException: class java.lang.Short cannot be cast to class java.lang.Integer (java.lang.Short and java.lang.Integer are in module java.base of loader 'bootstrap')
         at Baz$1$1.moveNext(Unknown Source)
         at org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.<init>(Linq4j.java:679)
    ```
    tindzk committed Mar 7, 2024
    Configuration menu
    Copy the full SHA
    50f208d View commit details
    Browse the repository at this point in the history