[jira] [Commented] (CALCITE-6284) Invalid conversion triggers ClassCastException
[ https://issues.apache.org/jira/browse/CALCITE-6284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17824169#comment-17824169 ] Julian Hyde commented on CALCITE-6284: -- Thank you! > Invalid conversion triggers ClassCastException > -- > > Key: CALCITE-6284 > URL: https://issues.apache.org/jira/browse/CALCITE-6284 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Tim Nieradzik >Priority: Major > > When passing an incompatible value (e.g. {{{}string{}}}) to a numeric > parameter (e.g. {{{}TINYINT{}}}) via a prepared statement, a > {{ClassCastException}} is thrown. > Test case: > {code:java} > @Test void bindStringParameter() { > for (SqlTypeName tpe : SqlTypeName.INT_TYPES) { > final String sql = > "with cte as (select cast(100 as " + tpe.getName() + ") as empid)" > + "select * from cte where empid = ?"; > CalciteAssert.hr() > .query(sql) > .consumesPreparedStatement(p -> { > p.setString(1, "100"); > }) > .returnsUnordered("EMPID=100"); > } > } {code} > Implement a validation with a more user-friendly message. > See also [GitHub > discussion|https://github.com/apache/calcite/pull/3687#discussion_r1489891786]. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (CALCITE-6284) Invalid conversion triggers ClassCastException
[ https://issues.apache.org/jira/browse/CALCITE-6284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17823900#comment-17823900 ] Tim Nieradzik commented on CALCITE-6284: [~julianhyde] Yes. I updated the description. > Invalid conversion triggers ClassCastException > -- > > Key: CALCITE-6284 > URL: https://issues.apache.org/jira/browse/CALCITE-6284 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Tim Nieradzik >Priority: Major > > When passing an incompatible value (e.g. {{{}string{}}}) to a numeric > parameter (e.g. {{{}TINYINT{}}}) via a prepared statement, a > {{ClassCastException}} is thrown. > Test case: > {code:java} > @Test void bindStringParameter() { > for (SqlTypeName tpe : SqlTypeName.INT_TYPES) { > final String sql = > "with cte as (select cast(100 as " + tpe.getName() + ") as empid)" > + "select * from cte where empid = ?"; > CalciteAssert.hr() > .query(sql) > .consumesPreparedStatement(p -> { > p.setString(1, "100"); > }) > .returnsUnordered("EMPID=100"); > } > } {code} > Implement a validation with a more user-friendly message. > See also [GitHub > discussion|https://github.com/apache/calcite/pull/3687#discussion_r1489891786]. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (CALCITE-6284) Invalid conversion triggers ClassCastException
[ https://issues.apache.org/jira/browse/CALCITE-6284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17823770#comment-17823770 ] Julian Hyde commented on CALCITE-6284: -- Can you fill out the description? Describe what's going on (and going wrong) in the test case. > Invalid conversion triggers ClassCastException > -- > > Key: CALCITE-6284 > URL: https://issues.apache.org/jira/browse/CALCITE-6284 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Tim Nieradzik >Priority: Major > > Test case: > {code:java} > @Test void bindStringParameter() { > for (SqlTypeName tpe : SqlTypeName.INT_TYPES) { > final String sql = > "with cte as (select cast(100 as " + tpe.getName() + ") as empid)" > + "select * from cte where empid = ?"; > CalciteAssert.hr() > .query(sql) > .consumesPreparedStatement(p -> { > p.setString(1, "100"); > }) > .returnsUnordered("EMPID=100"); > } > } {code} > This throws a {{ClassCastException}} which should be a more user-friendly > message. > Discussion: [https://github.com/apache/calcite/pull/3687]}}{}}} -- This message was sent by Atlassian Jira (v8.20.10#820010)