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

CompileException when cast TRUE to nullable boolean

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.9.1-incubating
    • None
    • None

    Description

      In contexts where boolean values can be null, we need to convert them to java.lang.Boolean. Query

      select case when deptno = 10 then null else true end
      from (values (10), (20)) as t(deptno)
      

      gives

      Caused by: org.codehaus.commons.compiler.CompileException: Line 25, Column 104: Incompatible expression types "java.lang.Boolean" and "boolean"
      	at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10064)
      	at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3643)
      	at org.codehaus.janino.UnitCompiler.access$6600(UnitCompiler.java:181)
      	at org.codehaus.janino.UnitCompiler$10.visitConditionalExpression(UnitCompiler.java:3268)
      

      from compiling the generated code

                  public Object current() {
                    return net.hydromatic.optiq.runtime.SqlFunctions.toInt(inputEnumerator.current()) == 10 ? (Boolean) null : true;
                  }
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: