[jira] [Commented] (CALCITE-6265) Cannot provide different numeric type as placeholder

2024-02-15 Thread Julian Hyde (Jira)


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

Julian Hyde commented on CALCITE-6265:
--

Sure, it shows up in Calcite, but it's due to Avatica not doing (what I claim 
to be) its job. If Avatica has a method that it says returns positive integers, 
and Calcite divides by the result of that method, Avatica is at fault, even 
though the divide-by-zero exception comes from Calcite code.

> 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
>  Labels: pull-request-available
>
> 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.(Linq4j.java:679)}}



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


[jira] [Commented] (CALCITE-6265) Cannot provide different numeric type as placeholder

2024-02-15 Thread Alessandro Solimando (Jira)


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

Alessandro Solimando commented on CALCITE-6265:
---

In principle I agree, but it seems that the code is failing on the execution at 
the "Enumerable" level, for this reason [~tnieradzik]'s PR is trying to apply 
coercion when building the Linq expression.

Not sure this is what you mean [~julianhyde], because that's still on the 
Calcite-side if I am not wrong, while you seem to suggest to look into the 
Avatica-side.

> 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
>  Labels: pull-request-available
>
> 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.(Linq4j.java:679)}}



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


[jira] [Commented] (CALCITE-6265) Cannot provide different numeric type as placeholder

2024-02-14 Thread Julian Hyde (Jira)


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

Julian Hyde commented on CALCITE-6265:
--

I think the bug is in Avatica - or at any rate, Avatica is the most logical 
place to fix it. If a parameter has type {{{}INTEGER{}}}, and a user calls 
{{{}PreparedStatement.setShort{}}}, it is Avatica's job to coerce that value to 
a {{{}java.lang.Integer{}}}.

It is analogous to – in fact, the reverse of – when someone calls 
{{ResultSet.getInt}} on a column that is of type {{{}SMALLINT{}}}. I believe 
that Avatica does that conversion already.

> 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
>  Labels: pull-request-available
>
> 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.(Linq4j.java:679)}}



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


[jira] [Commented] (CALCITE-6265) Cannot provide different numeric type as placeholder

2024-02-14 Thread Alessandro Solimando (Jira)


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

Alessandro Solimando commented on CALCITE-6265:
---

[~tnieradzik] I think it's worth mentioning in the ticket title that we are 
dealing with a prepared statement, I didn't get what placeholder meant until I 
saw the example, in the release notes we don't have them so it's better to 
improve the title too.

> 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
>  Labels: pull-request-available
>
> 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.(Linq4j.java:679)}}



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