Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6284

Invalid conversion triggers ClassCastException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • core
    • None

    Description

      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:

        @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");
          }
        } 

      Implement a validation with a more user-friendly message.

      See also GitHub discussion.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tnieradzik Tim Nieradzik
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: