Repository: flink
Updated Branches:
  refs/heads/master 166444767 -> fe018921e


http://git-wip-us.apache.org/repos/asf/flink/blob/fe018921/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/stream/table/stringexpr/OverWindowStringExpressionTest.scala
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/stream/table/stringexpr/OverWindowStringExpressionTest.scala
 
b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/stream/table/stringexpr/OverWindowStringExpressionTest.scala
new file mode 100644
index 0000000..0a5e001
--- /dev/null
+++ 
b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/stream/table/stringexpr/OverWindowStringExpressionTest.scala
@@ -0,0 +1,151 @@
+/*
+ * 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.flink.table.api.scala.stream.table.stringexpr
+
+import org.apache.flink.api.scala._
+import org.apache.flink.table.api.java.{Over => JOver}
+import org.apache.flink.table.api.scala.{Over => SOver, _}
+import org.apache.flink.table.utils.TableTestBase
+import org.junit.Test
+
+class OverWindowStringExpressionTest extends TableTestBase {
+
+  @Test
+  def testPartitionedUnboundedOverRow(): Unit = {
+    val util = streamTestUtil()
+    val t = util.addTable[(Long, Int, String, Int, Long)]('a, 'b, 'c, 'd, 'e)
+
+    val resScala = t
+      .window(SOver partitionBy 'a orderBy 'rowtime preceding UNBOUNDED_ROW as 
'w)
+      .select('a, 'b.sum over 'w)
+    val resJava = t
+      
.window(JOver.partitionBy("a").orderBy("rowtime").preceding("unbounded_row").as("w"))
+      .select("a, SUM(b) OVER w")
+
+    verifyTableEquals(resScala, resJava)
+  }
+
+  @Test
+  def testUnboundedOverRow(): Unit = {
+    val util = streamTestUtil()
+    val t = util.addTable[(Long, Int, String, Int, Long)]('a, 'b, 'c, 'd, 'e)
+
+    val resScala = t
+      .window(SOver orderBy 'rowtime preceding UNBOUNDED_ROW following 
CURRENT_ROW as 'w)
+      .select('a, 'b.sum over 'w)
+    val resJava = t
+      
.window(JOver.orderBy("rowtime").preceding("unbounded_row").following("current_row").as("w"))
+      .select("a, SUM(b) OVER w")
+
+    verifyTableEquals(resScala, resJava)
+  }
+
+  @Test
+  def testPartitionedBoundedOverRow(): Unit = {
+    val util = streamTestUtil()
+    val t = util.addTable[(Long, Int, String, Int, Long)]('a, 'b, 'c, 'd, 'e)
+
+    val resScala = t
+      .window(SOver partitionBy('a, 'd) orderBy 'rowtime preceding 10.rows as 
'w)
+      .select('a, 'b.sum over 'w)
+    val resJava = t
+      .window(JOver.partitionBy("a, 
d").orderBy("rowtime").preceding("10.rows").as("w"))
+      .select("a, SUM(b) OVER w")
+
+    verifyTableEquals(resScala, resJava)
+  }
+
+  @Test
+  def testBoundedOverRow(): Unit = {
+    val util = streamTestUtil()
+    val t = util.addTable[(Long, Int, String, Int, Long)]('a, 'b, 'c, 'd, 'e)
+
+    val resScala = t
+      .window(SOver orderBy 'rowtime preceding 10.rows following CURRENT_ROW 
as 'w)
+      .select('a, 'b.sum over 'w)
+    val resJava = t
+      
.window(JOver.orderBy("rowtime").preceding("10.rows").following("current_row").as("w"))
+      .select("a, SUM(b) OVER w")
+
+    verifyTableEquals(resScala, resJava)
+  }
+
+  @Test
+  def testPartitionedUnboundedOverRange(): Unit = {
+    val util = streamTestUtil()
+    val t = util.addTable[(Long, Int, String, Int, Long)]('a, 'b, 'c, 'd, 'e)
+
+    val resScala = t
+      .window(SOver partitionBy 'a orderBy 'rowtime preceding UNBOUNDED_RANGE 
as 'w)
+      .select('a, 'b.sum over 'w)
+    val resJava = t
+      
.window(JOver.partitionBy("a").orderBy("rowtime").preceding("unbounded_range").as("w"))
+      .select("a, SUM(b) OVER w")
+
+    verifyTableEquals(resScala, resJava)
+  }
+
+  @Test
+  def testUnboundedOverRange(): Unit = {
+    val util = streamTestUtil()
+    val t = util.addTable[(Long, Int, String, Int, Long)]('a, 'b, 'c, 'd, 'e)
+
+    val resScala = t
+      .window(SOver orderBy 'rowtime preceding UNBOUNDED_RANGE following 
CURRENT_RANGE as 'w)
+      .select('a, 'b.sum over 'w)
+    val resJava = t
+      .window(
+        
JOver.orderBy("rowtime").preceding("unbounded_range").following("current_range").as("w"))
+      .select("a, SUM(b) OVER w")
+
+    verifyTableEquals(resScala, resJava)
+  }
+
+  @Test
+  def testPartitionedBoundedOverRange(): Unit = {
+    val util = streamTestUtil()
+    val t = util.addTable[(Long, Int, String, Int, Long)]('a, 'b, 'c, 'd, 'e)
+
+    val resScala = t
+      .window(SOver partitionBy('a, 'c) orderBy 'rowtime preceding 10.minutes 
as 'w)
+      .select('a, 'b.sum over 'w)
+    val resJava = t
+      .window(JOver.partitionBy("a, 
c").orderBy("rowtime").preceding("10.minutes").as("w"))
+      .select("a, SUM(b) OVER w")
+
+    verifyTableEquals(resScala, resJava)
+  }
+
+  @Test
+  def testBoundedOverRange(): Unit = {
+    val util = streamTestUtil()
+    val t = util.addTable[(Long, Int, String, Int, Long)]('a, 'b, 'c, 'd, 'e)
+
+    val resScala = t
+      .window(SOver orderBy 'rowtime preceding 4.hours following CURRENT_RANGE 
as 'w)
+      .select('a, 'b.sum over 'w)
+    val resJava = t
+      
.window(JOver.orderBy("rowtime").preceding("4.hours").following("current_range").as("w"))
+      .select("a, SUM(b) OVER w")
+
+    verifyTableEquals(resScala, resJava)
+  }
+
+
+}

Reply via email to