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

CompileException when cast TRUE to nullable boolean

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.1-incubating
    • Component/s: None
    • Labels:
      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;
                  }
      

        Activity

        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-optiq/commit/dc89f1cd .

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development