You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by jn...@apache.org on 2015/06/26 20:45:59 UTC

[2/2] drill git commit: DRILL-3183: Enable compound identifier conversion in window defintion

DRILL-3183: Enable compound identifier conversion in window defintion


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

Branch: refs/heads/master
Commit: da17f28678f1dee5c43bdb69582586a79f8b667c
Parents: 80270d1
Author: Hsuan-Yi Chu <hs...@usc.edu>
Authored: Thu Jun 25 14:16:27 2015 -0700
Committer: Jinfeng Ni <jn...@apache.org>
Committed: Thu Jun 25 23:02:43 2015 -0700

----------------------------------------------------------------------
 .../sql/parser/CompoundIdentifierConverter.java |  2 +-
 .../apache/drill/exec/TestWindowFunctions.java  | 27 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/da17f286/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java
index fbc5f9b..f9032a4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java
@@ -150,7 +150,7 @@ public class CompoundIdentifierConverter extends SqlShuttle {
   //SqlNodeList orderBy,
   //SqlNode offset,
   //SqlNode fetch,
-    rules.put(SqlSelect.class, R(D, E, D, E, E, E, D, E, D, D));
+    rules.put(SqlSelect.class, R(D, E, D, E, E, E, E, E, D, D));
     rules.put(SqlCreateTable.class, R(D, D, D, E));
     rules.put(SqlCreateView.class, R(D, E, E, D));
     rules.put(SqlDescribeTable.class, R(D, D, E));

http://git-wip-us.apache.org/repos/asf/drill/blob/da17f286/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
index 5a7a07e..680f35b 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
@@ -19,6 +19,7 @@ package org.apache.drill.exec;
 
 import org.apache.drill.BaseTestQuery;
 import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.common.util.FileUtils;
 import org.apache.drill.common.util.TestTools;
 import org.apache.drill.exec.work.foreman.SqlUnsupportedException;
 import org.apache.drill.exec.work.foreman.UnsupportedFunctionException;
@@ -316,4 +317,30 @@ public class TestWindowFunctions extends BaseTestQuery {
         .go();
 
   }
+
+  @Test
+  public void testCompoundIdentifierInWindowDefinition() throws Exception {
+    String root = FileUtils.getResourceAsFile("/multilevel/csv/1994/Q1/orders_94_q1.csv").toURI().toString();
+    String query = String.format("SELECT count(*) OVER w as col1, count(*) OVER w as col2 \n" +
+        "FROM dfs_test.`%s` \n" +
+        "WINDOW w AS (PARTITION BY columns[1] ORDER BY columns[0] DESC)", root);
+
+    // Validate the result
+    testBuilder()
+        .sqlQuery(query)
+        .ordered()
+        .baselineColumns("col1", "col2")
+        .baselineValues((long) 1, (long) 1)
+        .baselineValues((long) 1, (long) 1)
+        .baselineValues((long) 1, (long) 1)
+        .baselineValues((long) 1, (long) 1)
+        .baselineValues((long) 1, (long) 1)
+        .baselineValues((long) 1, (long) 1)
+        .baselineValues((long) 1, (long) 1)
+        .baselineValues((long) 1, (long) 1)
+        .baselineValues((long) 1, (long) 1)
+        .baselineValues((long) 1, (long) 1)
+        .build()
+        .run();
+  }
 }