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

Tim Nieradzik updated CALCITE-6265:
-----------------------------------
    Description: 
The _empid_ column is of type {_}INT{_}. When providing a _short_ value as a 
placeholder, 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)}}

  was:
The `empid` column is of type `INT`. When providing a `short` value as a 
placeholder, 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)}}


> Cannot provide different numeric type as placeholder
> ----------------------------------------------------
>
>                 Key: CALCITE-6265
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6265
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Tim Nieradzik
>            Assignee: Tim Nieradzik
>            Priority: Major
>
> The _empid_ column is of type {_}INT{_}. When providing a _short_ value as a 
> placeholder, 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)}}



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

Reply via email to