You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by me...@apache.org on 2015/06/25 07:30:36 UTC
[2/5] drill git commit: DRILL-3359: Also detect the window frame
claimed in the window definition
DRILL-3359: Also detect the window frame claimed in the window definition
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/8b6fa14a
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/8b6fa14a
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/8b6fa14a
Branch: refs/heads/master
Commit: 8b6fa14acbf678ce8018799a15afea487247f011
Parents: 25b7b5e
Author: Hsuan-Yi Chu <hs...@usc.edu>
Authored: Wed Jun 24 15:31:25 2015 -0700
Committer: Mehant Baid <me...@gmail.com>
Committed: Wed Jun 24 16:14:14 2015 -0700
----------------------------------------------------------------------
.../sql/parser/UnsupportedOperatorsVisitor.java | 80 ++++++++++----------
.../apache/drill/exec/TestWindowFunctions.java | 14 ++++
2 files changed, 54 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/8b6fa14a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
index 0c5afc1..9bbd537 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
@@ -141,46 +141,6 @@ public class UnsupportedOperatorsVisitor extends SqlShuttle {
}
}
- // DRILL-3188
- // Disable frame which is other than the default
- // (i.e., BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
- if(((SqlCall) nodeInSelectList).operand(1) instanceof SqlWindow) {
- SqlWindow window = (SqlWindow) ((SqlCall) nodeInSelectList).operand(1);
-
- SqlNode lowerBound = window.getLowerBound();
- SqlNode upperBound = window.getUpperBound();
-
- // If no frame is specified
- // it is a default frame
- boolean isSupported = (lowerBound == null && upperBound == null);
-
- // When OVER clause contain an ORDER BY clause the following frames are equivalent to the default frame:
- // RANGE UNBOUNDED PRECEDING
- // RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
- if(window.getOrderList().size() != 0
- && !window.isRows()
- && SqlWindow.isUnboundedPreceding(lowerBound)
- && (upperBound == null || SqlWindow.isCurrentRow(upperBound))) {
- isSupported = true;
- }
-
- // When OVER clause doesn't contain an ORDER BY clause, the following are equivalent to the default frame:
- // RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
- // ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
- if(window.getOrderList().size() == 0
- && SqlWindow.isUnboundedPreceding(lowerBound)
- && SqlWindow.isUnboundedFollowing(upperBound)) {
- isSupported = true;
- }
-
- if(!isSupported) {
- unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.FUNCTION,
- "This type of window frame is currently not supported \n" +
- "See Apache Drill JIRA: DRILL-3188");
- throw new UnsupportedOperationException();
- }
- }
-
// DRILL-3196
// Disable multiple partitions in a SELECT-CLAUSE
SqlNode window = ((SqlCall) nodeInSelectList).operand(1);
@@ -214,6 +174,46 @@ public class UnsupportedOperatorsVisitor extends SqlShuttle {
}
}
+ // DRILL-3188
+ // Disable frame which is other than the default
+ // (i.e., BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ if(sqlCall instanceof SqlWindow) {
+ SqlWindow window = (SqlWindow) sqlCall;
+
+ SqlNode lowerBound = window.getLowerBound();
+ SqlNode upperBound = window.getUpperBound();
+
+ // If no frame is specified
+ // it is a default frame
+ boolean isSupported = (lowerBound == null && upperBound == null);
+
+ // When OVER clause contain an ORDER BY clause the following frames are equivalent to the default frame:
+ // RANGE UNBOUNDED PRECEDING
+ // RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ if(window.getOrderList().size() != 0
+ && !window.isRows()
+ && SqlWindow.isUnboundedPreceding(lowerBound)
+ && (upperBound == null || SqlWindow.isCurrentRow(upperBound))) {
+ isSupported = true;
+ }
+
+ // When OVER clause doesn't contain an ORDER BY clause, the following are equivalent to the default frame:
+ // RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ // ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ if(window.getOrderList().size() == 0
+ && SqlWindow.isUnboundedPreceding(lowerBound)
+ && SqlWindow.isUnboundedFollowing(upperBound)) {
+ isSupported = true;
+ }
+
+ if(!isSupported) {
+ unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.FUNCTION,
+ "This type of window frame is currently not supported \n" +
+ "See Apache Drill JIRA: DRILL-3188");
+ throw new UnsupportedOperationException();
+ }
+ }
+
// Disable unsupported Intersect, Except
if(sqlCall.getKind() == SqlKind.INTERSECT || sqlCall.getKind() == SqlKind.EXCEPT) {
unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.RELATIONAL,
http://git-wip-us.apache.org/repos/asf/drill/blob/8b6fa14a/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 2409005..5a7a07e 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
@@ -197,6 +197,20 @@ public class TestWindowFunctions extends BaseTestQuery {
}
}
+ @Test(expected = UnsupportedFunctionException.class) // DRILL-3359
+ public void testFramesDefinedInWindowClause() throws Exception {
+ try {
+ final String query = "explain plan for select sum(n_nationKey) over w \n" +
+ "from cp.`tpch/nation.parquet` \n" +
+ "window w as (partition by n_nationKey order by n_nationKey rows UNBOUNDED PRECEDING)";
+
+ test(query);
+ } catch(UserException ex) {
+ throwAsUnsupportedException(ex);
+ throw ex;
+ }
+ }
+
@Test(expected = UnsupportedFunctionException.class) // DRILL-3326
public void testWindowWithAlias() throws Exception {
try {