[
https://issues.apache.org/jira/browse/TAJO-774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14034894#comment-14034894
]
ASF GitHub Bot commented on TAJO-774:
-------------------------------------
Github user jihoonson commented on a diff in the pull request:
https://github.com/apache/tajo/pull/13#discussion_r13901471
--- 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);
+ return eq;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ WindowAggNode grp = (WindowAggNode) super.clone();
--- End diff --
SortSpec and hasDistinct flag also should be cloned.
> Implement logical plan part and physical executor for window function.
> ----------------------------------------------------------------------
>
> Key: TAJO-774
> URL: https://issues.apache.org/jira/browse/TAJO-774
> Project: Tajo
> Issue Type: Sub-task
> Components: planner/optimizer
> Reporter: Hyunsik Choi
> Assignee: Hyunsik Choi
> Fix For: 0.9.0
>
>
> See the title. The main objective of this issue is to implement the logical
> planning part for window function support.
--
This message was sent by Atlassian JIRA
(v6.2#6252)