Github user jihoonson commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/13#discussion_r13901459
  
    --- Diff: 
tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/WindowAggNode.java
 ---
    @@ -0,0 +1,230 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.tajo.engine.planner.logical;
    +
    +import com.google.gson.annotations.Expose;
    +import org.apache.tajo.catalog.Column;
    +import org.apache.tajo.catalog.SortSpec;
    +import org.apache.tajo.engine.eval.WindowFunctionEval;
    +import org.apache.tajo.engine.planner.PlanString;
    +import org.apache.tajo.engine.planner.PlannerUtil;
    +import org.apache.tajo.engine.planner.Target;
    +import org.apache.tajo.util.TUtil;
    +
    +public class WindowAggNode extends UnaryNode implements Projectable, 
Cloneable {
    +   /** partition key sets */
    +  @Expose private Column [] partitionKeys;
    +  /** order key sets */
    +  @Expose private SortSpec [] sortSpecs;
    +
    +  /** Aggregation Functions */
    +  @Expose private WindowFunctionEval[] windowFuncs;
    +  /**
    +   * It's a list of targets. The partition key columns should be followed 
by window functions.
    +   * aggrFunctions keep actual aggregation functions, but it only contains 
field references.
    +   * */
    +  @Expose private Target [] targets;
    +  @Expose private boolean hasDistinct = false;
    +
    +  public WindowAggNode(int pid) {
    +    super(pid, NodeType.WINDOW_AGG);
    +  }
    +
    +  public final boolean hasPartitionKeys() {
    +    return partitionKeys != null && partitionKeys.length > 0;
    +  }
    +
    +  public void setPartitionKeys(Column[] groupingColumns) {
    +    this.partitionKeys = groupingColumns;
    +  }
    +
    +   public final Column [] getPartitionKeys() {
    +     return this.partitionKeys;
    +   }
    +
    +  public final boolean hasSortSpecs() {
    +    return this.sortSpecs != null;
    +  }
    +
    +  public void setSortSpecs(SortSpec [] sortSpecs) {
    +    this.sortSpecs = sortSpecs;
    +  }
    +
    +  public final SortSpec [] getSortSpecs() {
    +    return this.sortSpecs;
    +  }
    +
    +  public final boolean isDistinct() {
    +    return hasDistinct;
    +  }
    +
    +  public void setDistinct(boolean distinct) {
    +    hasDistinct = distinct;
    +  }
    +
    +  public boolean hasAggFunctions() {
    +    return this.windowFuncs != null;
    +  }
    +
    +  public WindowFunctionEval [] getWindowFunctions() {
    +    return this.windowFuncs;
    +  }
    +
    +  public void setWindowFunctions(WindowFunctionEval[] evals) {
    +    this.windowFuncs = evals;
    +  }
    +
    +  @Override
    +  public boolean hasTargets() {
    +    return this.targets != null;
    +  }
    +
    +  @Override
    +  public void setTargets(Target[] targets) {
    +    this.targets = targets;
    +    setOutSchema(PlannerUtil.targetToSchema(targets));
    +  }
    +
    +  @Override
    +  public Target[] getTargets() {
    +    return this.targets;
    +  }
    +  
    +  public void setChild(LogicalNode subNode) {
    +    super.setChild(subNode);
    +  }
    +  
    +  public String toString() {
    +    StringBuilder sb = new StringBuilder("WinAgg (");
    +    if (hasPartitionKeys()) {
    +      sb.append("partition 
keys=").append(TUtil.arrayToString(partitionKeys));
    +      sb.append(", ");
    +    }
    +    if (hasAggFunctions()) {
    +      sb.append("funcs=").append(TUtil.arrayToString(windowFuncs));
    +    }
    +    if (hasSortSpecs()) {
    +      sb.append("sort=").append(TUtil.arrayToString(sortSpecs));
    +    }
    +    sb.append(")");
    +    return sb.toString();
    +  }
    +  
    +  @Override
    +  public boolean equals(Object obj) {
    +    if (obj instanceof WindowAggNode) {
    +      WindowAggNode other = (WindowAggNode) obj;
    +      boolean eq = super.equals(other);
    +      eq = eq && TUtil.checkEquals(partitionKeys, other.partitionKeys);
    +      eq = eq && TUtil.checkEquals(windowFuncs, other.windowFuncs);
    +      eq = eq && TUtil.checkEquals(targets, other.targets);
    --- End diff --
    
    SortSpec and hasDistinct flag also should be compared.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to