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

Linq4j code generation failure if one side of an OR contains unknown

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.18.0
    • None
    • None

    Description

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

      Running the following query:

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

      results in a compilation exception;
      the main problem is that there is an interesting field:

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

      full exception:

      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)
      

      Attachments

        Issue Links

          Activity

            People

              kgyrtkirk Zoltan Haindrich
              kgyrtkirk Zoltan Haindrich
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: