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

Error when implicitly converting character literal to date literal

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • None
    • 1.38.0
    • None
    • None

    Description

      The following query implicitly converts a character literal to a date literal; it passes validation but fails during code generation.

      select *
      from "scott".emp
      WHERE hiredate = '1980-12-17';
      +-------+-------+-------+------+------------+--------+------+--------+
      | EMPNO | ENAME | JOB   | MGR  | HIREDATE   | SAL    | COMM | DEPTNO |
      +-------+-------+-------+------+------------+--------+------+--------+
      |  7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 |      |     20 |
      +-------+-------+-------+------+------------+--------+------+--------+
      (1 row)
      
      !ok
      

      throws

      Error while compiling generated Java code:
      	at org.apache.calcite.avatica.Helper.wrap(Helper.java:37)
      	at org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:108)
      	at org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1261)
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:330)
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:229)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:786)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:640)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:610)
      	at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:221)
      	at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603)
      	at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638)
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149)
      	... 9 more
      Caused by: org.codehaus.commons.compiler.CompileException: Line 17, Column 46: Incomparable types 'java.lang.Integer' and 'java.lang.String'
      	at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10092)
      	at org.codehaus.janino.UnitCompiler.compileBoolean2(UnitCompiler.java:3080)
      
      

      I have added the test case to misc.iq.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              julianhyde Julian Hyde
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: