tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sir...@apache.org
Subject tajo git commit: TAJO-1287: Repeated using of the same order by key in multiple window clauses should be supported. (Keuntae Park)
Date Fri, 09 Jan 2015 06:24:13 GMT
Repository: tajo
Updated Branches:
  refs/heads/master 307c6c9f5 -> 03801a312


TAJO-1287: Repeated using of the same order by key in multiple window clauses should be supported.
(Keuntae Park)

Closes #337


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/03801a31
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/03801a31
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/03801a31

Branch: refs/heads/master
Commit: 03801a3129301745e16f0a7b40102a56e9d13389
Parents: 307c6c9
Author: Keuntae Park <sirpkt@apache.org>
Authored: Fri Jan 9 15:22:11 2015 +0900
Committer: Keuntae Park <sirpkt@apache.org>
Committed: Fri Jan 9 15:22:11 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |  3 ++
 .../engine/planner/physical/WindowAggExec.java  | 11 +++++++-
 .../tajo/engine/query/TestWindowQuery.java      | 29 ++++++++++++++++++++
 3 files changed, 42 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/03801a31/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 35670d7..66bb299 100644
--- a/CHANGES
+++ b/CHANGES
@@ -154,6 +154,9 @@ Release 0.9.1 - unreleased
 
   BUG FIXES
 
+    TAJO-1287: Repeated using of the same order by key in multiple 
+    window clauses should be supported. (Keuntae Park)
+
     TAJO-1265: min(), max() does not handle null properly. (Keuntae Park)
 
     TAJO-1270: Fix typos. (DaeMyung Kang via hyunsik)

http://git-wip-us.apache.org/repos/asf/tajo/blob/03801a31/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/WindowAggExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/WindowAggExec.java
b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/WindowAggExec.java
index e36dcd8..a36bd4f 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/WindowAggExec.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/WindowAggExec.java
@@ -143,7 +143,16 @@ public class WindowAggExec extends UnaryPhysicalExec {
 
           for (SortSpec sortSpec : functions[i].getSortSpecs()) {
             if (!rewrittenSchema.contains(sortSpec.getSortKey())) {
-              additionalSortKeyColumns.add(sortSpec.getSortKey());
+              // check if additionalSortKeyColumns already has that sort key
+              boolean newKey = true;
+              for (Column c : additionalSortKeyColumns) {
+                if (c.equals(sortSpec.getSortKey())) {
+                  newKey = false;
+                }
+              }
+              if (newKey) {
+                additionalSortKeyColumns.add(sortSpec.getSortKey());
+              }
             }
           }
         }

http://git-wip-us.apache.org/repos/asf/tajo/blob/03801a31/tajo-core/src/test/java/org/apache/tajo/engine/query/TestWindowQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestWindowQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestWindowQuery.java
index 668ba70..14ab58f 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestWindowQuery.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestWindowQuery.java
@@ -321,4 +321,33 @@ public class TestWindowQuery extends QueryTestCaseBase {
       executeString("DROP TABLE lastvaluetime PURGE");
     }
   }
+
+  @Test
+  public final void testMultipleWindow() throws Exception {
+    KeyValueSet tableOptions = new KeyValueSet();
+    tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);
+    tableOptions.set(StorageConstants.TEXT_NULL, "\\\\N");
+
+    Schema schema = new Schema();
+    schema.addColumn("id", TajoDataTypes.Type.INT4);
+    schema.addColumn("time", TajoDataTypes.Type.TIME);
+    schema.addColumn("name", TajoDataTypes.Type.TEXT);
+    String[] data = new String[]{ "1|12:11:12|abc", "2|10:11:13|def", "2|05:42:41|ghi" };
+    TajoTestingCluster.createTable("multiwindow", schema, tableOptions, data, 1);
+
+    try {
+      ResultSet res = executeString(
+          "select id, last_value(time) over ( partition by id order by time ) as time_last,
last_value(name) over ( partition by id order by time ) as name_last from multiwindow");
+      String ascExpected = "id,time_last,name_last\n" +
+          "-------------------------------\n" +
+          "1,12:11:12,abc\n" +
+          "2,10:11:13,def\n" +
+          "2,10:11:13,def\n";
+
+      assertEquals(ascExpected, resultSetToString(res));
+      res.close();
+    } finally {
+      executeString("DROP TABLE multiwindow PURGE");
+    }
+  }
 }
\ No newline at end of file


Mime
View raw message