Uploaded image for project: 'Kylin'
  1. Kylin
  2. KYLIN-3637

Union All not working with count()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • None

    Description

      From user@kylin mailing list:

      When I ran sql "SELECT count(TRANS_ID) as TRANS_ID FROM KYLIN_SALES where
      TRANS_ID <> 1 union all select count(TRANS_ID) as TRANS_ID FROM KYLIN_SALES"
      on sample cube.

      Got Error:
      Error while compiling generated Java code: public static class Record2_1
      implements java.io.Serializable { public Long TRANS_ID; public long
      KY_COUNT_; public Record2_1() {} public boolean equals(Object o)

      { if (this == o) \{ return true; }

      if (!(o instanceof Record2_1))

      { return false; }

      return java.util.Objects.equals(this.TRANS_ID, ((Record2_1) o).TRANS_ID)
      && this.KY_COUNT_ == ((Record2_1) o).KY_COUNT_; } public int hashCode()

      { int h = 0; h = org.apache.calcite.runtime.Utilities.hash(h, this.TRANS_ID); h = org.apache.calcite.runtime.Utilities.hash(h, this._KY_COUNT__); return h; }

      public int compareTo(Record2_1 that)

      { int c; c = org.apache.calcite.runtime.Utilities.compareNullsLast(this.TRANS_ID, that.TRANS_ID); if (c != 0) \{ return c; }

      c =
      org.apache.calcite.runtime.Utilities.compare(this.KY_COUNT_,
      that.KY_COUNT_); if (c != 0) { return c; } return 0; } public String
      toString() { return "

      {TRANS_ID=" + this.TRANS_ID + ", _KY_COUNT__=" + this._KY_COUNT__ + "}

      "; } } public static class Record1_0 implements
      java.io.Serializable { public long f0; public Record1_0() {} public boolean
      equals(Object o) { if (this == o)

      { return true; } if (!(o instanceof
      Record1_0)) { return false; } return this.f0 == ((Record1_0) o).f0; } public
      int hashCode() { int h = 0; h = org.apache.calcite.runtime.Utilities.hash(h, this.f0); return h; } public int compareTo(Record1_0 that) { final int c; c = org.apache.calcite.runtime.Utilities.compare(this.f0, that.f0); if (c != 0) \{ return c; } return 0; } public String toString() { return "{f0=" + this.f0 + "}"; } } org.apache.calcite.DataContext root; public
      org.apache.calcite.linq4j.Enumerable bind(final
      org.apache.calcite.DataContext root0) { root = root0; final
      org.apache.calcite.linq4j.Enumerable _inputEnumerable =
      ((org.apache.kylin.query.schema.OLAPTable)
      root.getRootSchema().getSubSchema("DEFAULT").getTable("KYLIN_SALES")).executeOLAPQuery(root,
      1); final org.apache.calcite.linq4j.AbstractEnumerable child = 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 =
      _inputEnumerable.enumerator(); public void reset() { inputEnumerator.reset(); } public boolean moveNext() { while
      (inputEnumerator.moveNext()) { final Long inp0_ = (Long) ((Object[])
      inputEnumerator.current())[0]; if (inp0_ != null && inp0_.longValue() != 1L){ return true; }

      } return false; } public void close()

      { inputEnumerator.close(); }

      public Object current() { final Object[] current
      = (Object[]) inputEnumerator.current(); return new Object[]

      { current[0], current[11]}

      ; } }; } }; final org.apache.calcite.linq4j.Enumerable
      _inputEnumerable0 = ((org.apache.kylin.query.schema.OLAPTable)
      root.getRootSchema().getSubSchema("DEFAULT").getTable("KYLIN_SALES")).executeOLAPQuery(root,
      2); final org.apache.calcite.linq4j.AbstractEnumerable child1 = 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 =
      _inputEnumerable0.enumerator(); public void reset()

      { inputEnumerator.reset(); }

      public boolean moveNext()

      { return inputEnumerator.moveNext(); }

      public void close()

      { inputEnumerator.close(); }

      public Object current()

      { final Object[] current = (Object[]) inputEnumerator.current(); return new Record2_1( (Long) current[0], org.apache.calcite.runtime.SqlFunctions.toLong(current[11])); }

      }; } };
      return
      org.apache.calcite.linq4j.Linq4j.singletonEnumerable(child.aggregate(new
      org.apache.calcite.linq4j.function.Function0() { public Object apply()

      { long a0s0; a0s0 = 0; Record1_0 record0; record0 = new Record1_0(); record0.f0 = a0s0; return record0; } } .apply(), new
      org.apache.calcite.linq4j.function.Function2() { public Record1_0
      apply(Record1_0 acc, Object[] in) { acc.f0 = acc.f0 + org.apache.calcite.runtime.SqlFunctions.toLong(in[1]); return acc; } public
      Record1_0 apply(Object acc, Object in) { return apply( (Record1_0) acc, (Object[]) in); } } , new org.apache.calcite.linq4j.function.Function1() { public long apply(Record1_0 acc) \{ return acc.f0; } public Object
      apply(Object acc) { return apply( (Record1_0) acc); } }
      )).concat(org.apache.calcite.linq4j.Linq4j.singletonEnumerable(child1.aggregate(new
      org.apache.calcite.linq4j.function.Function0() { public Object apply() { long a0s0; a0s0 = 0; Record1_0 record0; record0 = new Record1_0(); record0.f0 = a0s0; return record0; }

      } .apply(), new
      org.apache.calcite.linq4j.function.Function2() { public Record1_0
      apply(Record1_0 acc, Record2_1 in)

      { acc.f0 = acc.f0 + in._KY_COUNT__; return acc; }

      public Record1_0 apply(Object acc, Object in)

      { return apply( (Record1_0) acc, (Record2_1) in); }

      } , new
      org.apache.calcite.linq4j.function.Function1()

      { public long apply(Record1_0 acc) \{ return acc.f0; }

      public Object apply(Object acc)

      { return apply( (Record1_0) acc); }

      } ))).take(50000); } public Class getElementType()

      { return long.class; }

      while executing SQL: "SELECT count(TRANS_ID) as
      TRANS_ID FROM KYLIN_SALES where TRANS_ID <> 1 union all select
      count(TRANS_ID) as TRANS_ID FROM KYLIN_SALES LIMIT 50000"

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              shaofengshi Shao Feng Shi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: