Zoltan Haindrich created CALCITE-2611:
-----------------------------------------

             Summary: Code generation fails if one side of an or contains 
unknown
                 Key: CALCITE-2611
                 URL: https://issues.apache.org/jira/browse/CALCITE-2611
             Project: Calcite
          Issue Type: Bug
            Reporter: Zoltan Haindrich
            Assignee: Julian Hyde


This is rather strange...it needs also an and below which contains the unknown.

Running the following query: 

{code}
!connect jdbc:calcite:model=target/test-classes/model.json admin admin
select (EMPID = 3 and unknown) or ( EMPID  = 3) from emps;
{code}

results in a compilation exception;
the main problem is that there is an interesting field:
{code}
static final Object $L4J$C$_null = !null;
{code}

full exception:

{code}
0: jdbc:calcite:model=target/test-classes/mod> select (cast(EMPID as integer) = 
3 and unknown) or not ( cast(EMPID as integer) = 3) from emps;
Error: Error while executing SQL "select (cast(EMPID as integer) = 3 and 
unknown) or not ( cast(EMPID as integer) = 3) from emps": Error while compiling 
generated Java code:
org.apache.calcite.DataContext root;

public org.apache.calcite.linq4j.Enumerable bind(final 
org.apache.calcite.DataContext root0) {
  root = root0;
  final org.apache.calcite.rel.RelNode v1stashed = 
(org.apache.calcite.rel.RelNode) root.get("v1stashed");
  final org.apache.calcite.interpreter.Interpreter interpreter = new 
org.apache.calcite.interpreter.Interpreter(
    root,
    v1stashed);
  return new org.apache.calcite.linq4j.AbstractEnumerable(){
      public org.apache.calcite.linq4j.Enumerator enumerator() {
        return new org.apache.calcite.linq4j.Enumerator(){
            public final org.apache.calcite.linq4j.Enumerator inputEnumerator = 
interpreter.enumerator();
            public void reset() {
              inputEnumerator.reset();
            }

            public boolean moveNext() {
              return inputEnumerator.moveNext();
            }

            public void close() {
              inputEnumerator.close();
            }

            public Object current() {
              final Integer inp5_ = (Integer) ((Object[]) 
inputEnumerator.current())[5];
              return inp5_ != null && inp5_.intValue() != 3 ? Boolean.TRUE : 
inp5_ != null || $L4J$C$_null || inp5_ == null ? (Boolean) null : Boolean.FALSE;
            }

            static final Object $L4J$C$_null = !null;
          };
      }

    };
}


public Class getElementType() {
  return java.lang.Boolean.class;
} (state=,code=0)
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to