Repository: calcite
Updated Branches:
  refs/heads/master a11d14054 -> fa308a30a


Split tests for MATCH_RECOGNIZE validation into their own class


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

Branch: refs/heads/master
Commit: 86b9ed7be78d758b4b95b8ec589ceab90927af42
Parents: a11d140
Author: Julian Hyde <[email protected]>
Authored: Wed May 3 09:51:56 2017 -0700
Committer: Julian Hyde <[email protected]>
Committed: Wed May 3 09:57:55 2017 -0700

----------------------------------------------------------------------
 .../org/apache/calcite/test/CalciteSuite.java   |   1 +
 .../calcite/test/SqlValidatorMatchTest.java     | 164 +++++++++++++++++++
 .../apache/calcite/test/SqlValidatorTest.java   | 137 ----------------
 3 files changed, 165 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/86b9ed7b/core/src/test/java/org/apache/calcite/test/CalciteSuite.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/CalciteSuite.java 
b/core/src/test/java/org/apache/calcite/test/CalciteSuite.java
index e64422d..b56f73e 100644
--- a/core/src/test/java/org/apache/calcite/test/CalciteSuite.java
+++ b/core/src/test/java/org/apache/calcite/test/CalciteSuite.java
@@ -119,6 +119,7 @@ import org.junit.runners.Suite;
     SqlSetOptionOperatorTest.class,
     SqlPrettyWriterTest.class,
     SqlValidatorTest.class,
+    SqlValidatorMatchTest.class,
     SqlAdvisorTest.class,
     RelMetadataTest.class,
     DateRangeRulesTest.class,

http://git-wip-us.apache.org/repos/asf/calcite/blob/86b9ed7b/core/src/test/java/org/apache/calcite/test/SqlValidatorMatchTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/test/SqlValidatorMatchTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlValidatorMatchTest.java
new file mode 100644
index 0000000..144c43c
--- /dev/null
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorMatchTest.java
@@ -0,0 +1,164 @@
+/*
+ * 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.calcite.test;
+
+import org.junit.Test;
+
+/**
+ * Validation tests for the {@code MATCH_RECOGNIZE} clause.
+ */
+public class SqlValidatorMatchTest extends SqlValidatorTestCase {
+  /** Tries to create a calls to some internal operators in
+   * MATCH_RECOGNIZE. Should fail. */
+  @Test public void testMatchRecognizeInternals() throws Exception {
+    sql("values ^pattern_exclude(1, 2)^")
+        .fails("No match found for function signature .*");
+    sql("values ^\"|\"(1, 2)^")
+        .fails("No match found for function signature .*");
+      // FINAL and other functions should not be visible outside of
+      // MATCH_RECOGNIZE
+    sql("values ^\"FINAL\"(1, 2)^")
+        .fails("No match found for function signature FINAL\\(<NUMERIC>, 
<NUMERIC>\\)");
+    sql("values ^\"RUNNING\"(1, 2)^")
+        .fails("No match found for function signature RUNNING\\(<NUMERIC>, 
<NUMERIC>\\)");
+    sql("values ^\"FIRST\"(1, 2)^")
+        .fails("Function 'FIRST\\(1, 2\\)' can only be used in 
MATCH_RECOGNIZE");
+    sql("values ^\"LAST\"(1, 2)^")
+        .fails("Function 'LAST\\(1, 2\\)' can only be used in 
MATCH_RECOGNIZE");
+    sql("values ^\"PREV\"(1, 2)^")
+        .fails("Function 'PREV\\(1, 2\\)' can only be used in 
MATCH_RECOGNIZE");
+  }
+
+  @Test public void testMatchRecognizeDefines() throws Exception {
+    final String sql = "select *\n"
+      + "  from emp match_recognize (\n"
+      + "    pattern (strt down+ up+)\n"
+      + "    define\n"
+      + "      down as down.sal < PREV(down.sal),\n"
+      + "      up as up.sal > PREV(up.sal)\n"
+      + "  ) mr";
+    sql(sql).ok();
+  }
+
+  @Test public void testMatchRecognizeDefines2() throws Exception {
+    final String sql = "select *\n"
+      + "  from t match_recognize (\n"
+      + "    pattern (strt down+ up+)\n"
+      + "    define\n"
+      + "      down as down.price < PREV(down.price),\n"
+      + "      ^down as up.price > PREV(up.price)^\n"
+      + "  ) mr";
+    sql(sql).fails("Pattern variable 'DOWN' has already been defined");
+  }
+
+  @Test public void testMatchRecognizeDefines3() throws Exception {
+    final String sql = "select *\n"
+      + "  from emp match_recognize (\n"
+      + "    pattern (strt down+up+)\n"
+      + "    define\n"
+      + "      down as down.sal < PREV(down.sal),\n"
+      + "      up as up.sal > PREV(up.sal)\n"
+      + "  ) mr";
+    sql(sql).ok();
+  }
+
+  @Test public void testMatchRecognizeDefines4() throws Exception {
+    final String sql = "select *\n"
+        + "  from emp match_recognize (\n"
+        + "    pattern (strt down+ up+)\n"
+        + "    define\n"
+        + "      down as down.sal < PREV(down.sal),\n"
+        + "      up as up.sal > FIRST(^PREV(up.sal)^)\n"
+        + "  ) mr";
+    sql(sql)
+        .fails("Cannot nest PREV/NEXT under LAST/FIRST 'PREV\\(`UP`\\.`SAL`, 
1\\)'");
+  }
+
+  @Test public void testMatchRecognizeDefines5() throws Exception {
+    final String sql = "select *\n"
+        + "  from emp match_recognize (\n"
+        + "    pattern (strt down+ up+)\n"
+        + "    define\n"
+        + "      down as down.sal < PREV(down.sal),\n"
+        + "      up as up.sal > FIRST(^FIRST(up.sal)^)\n"
+        + "  ) mr";
+    sql(sql)
+        .fails("Cannot nest PREV/NEXT under LAST/FIRST 'FIRST\\(`UP`\\.`SAL`, 
0\\)'");
+  }
+
+  @Test public void testMatchRecognizeDefines6() throws Exception {
+    final String sql = "select *\n"
+        + "  from emp match_recognize (\n"
+        + "    pattern (strt down+ up+)\n"
+        + "    define\n"
+        + "      down as down.sal < PREV(down.sal),\n"
+        + "      up as up.sal > ^COUNT(down.sal, up.sal)^\n"
+        + "  ) mr";
+    sql(sql)
+        .fails("Invalid number of parameters to COUNT method");
+  }
+
+  @Test public void testMatchRecognizeMeasures1() throws Exception {
+    final String sql = "select *\n"
+        + "  from emp match_recognize (\n"
+        + "    measures STRT.sal as start_sal,"
+        + "      ^LAST(null)^ as bottom_sal,"
+        + "      LAST(up.ts) as end_sal"
+        + "    pattern (strt down+ up+)\n"
+        + "    define\n"
+        + "      down as down.sal < PREV(down.sal),\n"
+        + "      up as up.sal > prev(up.sal)\n"
+        + "  ) mr";
+    sql(sql)
+        .fails("Null parameters in 'LAST\\(NULL, 0\\)'");
+  }
+
+  @Test public void testMatchRecognizeSkipTo1() throws Exception {
+    final String sql = "select *\n"
+        + "  from emp match_recognize (\n"
+        + "    after match skip to ^null^\n"
+        + "    measures\n"
+        + "      STRT.sal as start_sal,\n"
+        + "      LAST(up.ts) as end_sal\n"
+        + "    pattern (strt down+ up+)\n"
+        + "    define\n"
+        + "      down as down.sal < PREV(down.sal),\n"
+        + "      up as up.sal > prev(up.sal)\n"
+        + "  ) mr";
+    sql(sql)
+        .fails("(?s).*Encountered \"to null\" at .*");
+  }
+
+  @Test public void testMatchRecognizeSkipTo2() throws Exception {
+    final String sql = "select *\n"
+        + "  from emp match_recognize (\n"
+        + "    after match skip to ^no_exists^\n"
+        + "    measures\n"
+        + "      STRT.sal as start_sal,"
+        + "      LAST(up.ts) as end_sal"
+        + "    pattern (strt down+ up+)\n"
+        + "    define\n"
+        + "      down as down.sal < PREV(down.sal),\n"
+        + "      up as up.sal > prev(up.sal)\n"
+        + "  ) mr";
+    sql(sql)
+        .fails("(?s).*Encountered \"measures\" at .*");
+  }
+
+}
+
+// End SqlValidatorMatchTest.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/86b9ed7b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
index 95fdef0..03faca7 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -9309,96 +9309,6 @@ public class SqlValidatorTest extends 
SqlValidatorTestCase {
         + "group by session(rowtime, interval '1' hour)").ok();
   }
 
-  /** Tries to create a calls to some internal operators in
-   * MATCH_RECOGNIZE. Should fail. */
-  @Test public void testMatchRecognizeInternals() throws Exception {
-    sql("values ^pattern_exclude(1, 2)^")
-        .fails("No match found for function signature .*");
-    sql("values ^\"|\"(1, 2)^")
-        .fails("No match found for function signature .*");
-      // FINAL and other functions should not be visible outside of
-      // MATCH_RECOGNIZE
-    sql("values ^\"FINAL\"(1, 2)^")
-        .fails("No match found for function signature FINAL\\(<NUMERIC>, 
<NUMERIC>\\)");
-    sql("values ^\"RUNNING\"(1, 2)^")
-        .fails("No match found for function signature RUNNING\\(<NUMERIC>, 
<NUMERIC>\\)");
-    sql("values ^\"FIRST\"(1, 2)^")
-        .fails("Function 'FIRST\\(1, 2\\)' can only be used in 
MATCH_RECOGNIZE");
-    sql("values ^\"LAST\"(1, 2)^")
-        .fails("Function 'LAST\\(1, 2\\)' can only be used in 
MATCH_RECOGNIZE");
-    sql("values ^\"PREV\"(1, 2)^")
-        .fails("Function 'PREV\\(1, 2\\)' can only be used in 
MATCH_RECOGNIZE");
-  }
-
-  @Test public void testMatchRecognizeDefines() throws Exception {
-    final String sql = "select *\n"
-      + "  from emp match_recognize (\n"
-      + "    pattern (strt down+ up+)\n"
-      + "    define\n"
-      + "      down as down.sal < PREV(down.sal),\n"
-      + "      up as up.sal > PREV(up.sal)\n"
-      + "  ) mr";
-    sql(sql).ok();
-  }
-
-  @Test public void testMatchRecognizeDefines2() throws Exception {
-    final String sql = "select *\n"
-      + "  from t match_recognize (\n"
-      + "    pattern (strt down+ up+)\n"
-      + "    define\n"
-      + "      down as down.price < PREV(down.price),\n"
-      + "      ^down as up.price > PREV(up.price)^\n"
-      + "  ) mr";
-    sql(sql).fails("Pattern variable 'DOWN' has already been defined");
-  }
-
-  @Test public void testMatchRecognizeDefines3() throws Exception {
-    final String sql = "select *\n"
-      + "  from emp match_recognize (\n"
-      + "    pattern (strt down+up+)\n"
-      + "    define\n"
-      + "      down as down.sal < PREV(down.sal),\n"
-      + "      up as up.sal > PREV(up.sal)\n"
-      + "  ) mr";
-    sql(sql).ok();
-  }
-
-  @Test public void testMatchRecognizeDefines4() throws Exception {
-    final String sql = "select *\n"
-        + "  from emp match_recognize (\n"
-        + "    pattern (strt down+ up+)\n"
-        + "    define\n"
-        + "      down as down.sal < PREV(down.sal),\n"
-        + "      up as up.sal > FIRST(^PREV(up.sal)^)\n"
-        + "  ) mr";
-    sql(sql)
-        .fails("Cannot nest PREV/NEXT under LAST/FIRST 'PREV\\(`UP`\\.`SAL`, 
1\\)'");
-  }
-
-  @Test public void testMatchRecognizeDefines5() throws Exception {
-    final String sql = "select *\n"
-        + "  from emp match_recognize (\n"
-        + "    pattern (strt down+ up+)\n"
-        + "    define\n"
-        + "      down as down.sal < PREV(down.sal),\n"
-        + "      up as up.sal > FIRST(^FIRST(up.sal)^)\n"
-        + "  ) mr";
-    sql(sql)
-        .fails("Cannot nest PREV/NEXT under LAST/FIRST 'FIRST\\(`UP`\\.`SAL`, 
0\\)'");
-  }
-
-  @Test public void testMatchRecognizeDefines6() throws Exception {
-    final String sql = "select *\n"
-        + "  from emp match_recognize (\n"
-        + "    pattern (strt down+ up+)\n"
-        + "    define\n"
-        + "      down as down.sal < PREV(down.sal),\n"
-        + "      up as up.sal > ^COUNT(down.sal, up.sal)^\n"
-        + "  ) mr";
-    sql(sql)
-        .fails("Invalid number of parameters to COUNT method");
-  }
-
   @Test public void testInsertExtendedColumn() {
     sql("insert into empdefaults(extra BOOLEAN, note VARCHAR)"
         + " (deptno, empno, ename, extra, note) values (1, 10, '2', true, 
'ok')").ok();
@@ -9787,53 +9697,6 @@ public class SqlValidatorTest extends 
SqlValidatorTestCase {
         "Duplicate name 'EXTRA' in column list");
   }
 
-  @Test public void testMatchRecognizeMeasures1() throws Exception {
-    final String sql = "select *\n"
-        + "  from emp match_recognize (\n"
-        + "    measures STRT.sal as start_sal,"
-        + "      ^LAST(null)^ as bottom_sal,"
-        + "      LAST(up.ts) as end_sal"
-        + "    pattern (strt down+ up+)\n"
-        + "    define\n"
-        + "      down as down.sal < PREV(down.sal),\n"
-        + "      up as up.sal > prev(up.sal)\n"
-        + "  ) mr";
-    sql(sql)
-      .fails("Null parameters in 'LAST\\(NULL, 0\\)'");
-  }
-
-  @Test public void testMatchRecognizeSkipTo1() throws Exception {
-    final String sql = "select *\n"
-        + "  from emp match_recognize (\n"
-        + "    after match skip to ^null^\n"
-        + "    measures\n"
-        + "      STRT.sal as start_sal,\n"
-        + "      LAST(up.ts) as end_sal\n"
-        + "    pattern (strt down+ up+)\n"
-        + "    define\n"
-        + "      down as down.sal < PREV(down.sal),\n"
-        + "      up as up.sal > prev(up.sal)\n"
-        + "  ) mr";
-    sql(sql)
-        .fails("(?s).*Encountered \"to null\" at .*");
-  }
-
-  @Test public void testMatchRecognizeSkipTo2() throws Exception {
-    final String sql = "select *\n"
-        + "  from emp match_recognize (\n"
-        + "    after match skip to ^no_exists^\n"
-        + "    measures\n"
-        + "      STRT.sal as start_sal,"
-        + "      LAST(up.ts) as end_sal"
-        + "    pattern (strt down+ up+)\n"
-        + "    define\n"
-        + "      down as down.sal < PREV(down.sal),\n"
-        + "      up as up.sal > prev(up.sal)\n"
-        + "  ) mr";
-    sql(sql)
-        .fails("(?s).*Encountered \"measures\" at .*");
-  }
-
 }
 
 // End SqlValidatorTest.java

Reply via email to