flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] wuchong commented on a change in pull request #8244: [FLINK-11945] [table-runtime-blink] Support over aggregation for blink streaming runtime
Date Sun, 05 May 2019 13:53:05 GMT
wuchong commented on a change in pull request #8244: [FLINK-11945] [table-runtime-blink] Support
over aggregation for blink streaming runtime
URL: https://github.com/apache/flink/pull/8244#discussion_r281020373
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/runtime/harness/OverWindowHarnessTest.scala
 ##########
 @@ -0,0 +1,975 @@
+/*
+ * 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.runtime.harness
+
+import java.lang.{Long => JLong}
+import java.util.concurrent.ConcurrentLinkedQueue
+
+import org.apache.flink.api.scala._
+import org.apache.flink.api.common.time.Time
+import org.apache.flink.streaming.api.TimeCharacteristic
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord
+import org.apache.flink.table.api.Types
+import org.apache.flink.table.api.scala._
+import org.apache.flink.table.dataformat.BinaryString.fromString
+import org.apache.flink.table.dataformat.{BinaryRow, BinaryRowWriter, BinaryString, GenericRow}
+import org.apache.flink.table.runtime.utils.BaseRowHarnessAssertor
+import org.apache.flink.table.runtime.utils.StreamingWithStateTestBase.StateBackendMode
+import org.apache.flink.types.Row
+import org.junit.{Ignore, Test}
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+
+import scala.collection.mutable
+
+@Ignore
+@RunWith(classOf[Parameterized])
+class OverWindowHarnessTest(mode: StateBackendMode) extends HarnessTestBase(mode) {
+
+  @Test
+  def testProcTimeBoundedRowsOver(): Unit = {
+
+    val data = new mutable.MutableList[(Long, String, Long)]
+    val t = env.fromCollection(data).toTable(tEnv, 'currtime, 'b, 'c, 'proctime)
+    tEnv.registerTable("T", t)
+
+    val sql =
+      """
+        |SELECT currtime, b, c,
+        | min(c) OVER
+        |   (PARTITION BY b ORDER BY proctime ROWS BETWEEN 1 PRECEDING AND CURRENT ROW),
+        | max(c) OVER
+        |   (PARTITION BY b ORDER BY proctime ROWS BETWEEN 1 PRECEDING AND CURRENT ROW)
+        |FROM T
+      """.stripMargin
+    val t1 = tEnv.sqlQuery(sql)
+
+    tEnv.getConfig.withIdleStateRetentionTime(Time.seconds(2), Time.seconds(3))
+    val testHarness = createHarnessTester(t1.toAppendStream[Row], "over")
+    val assertor = new BaseRowHarnessAssertor(
+      Array(Types.LONG, Types.STRING, Types.LONG, Types.LONG, Types.LONG, Types.LONG, Types.LONG))
+
+    testHarness.open()
+
+    // register cleanup timer with 3001
+    testHarness.setProcessingTime(1)
+
+    testHarness.processElement(new StreamRecord(
+      binaryRow(1L: JLong, "aaa", 1L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(1L: JLong, "bbb", 10L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(1L: JLong, "aaa", 2L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(1L: JLong, "aaa", 3L: JLong, hasProcTime = true)))
+
+    // register cleanup timer with 4100
+    testHarness.setProcessingTime(1100)
+    testHarness.processElement(new StreamRecord(
+      binaryRow(1L: JLong, "bbb", 20L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(1L: JLong, "aaa", 4L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(1L: JLong, "aaa", 5L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(1L: JLong, "aaa", 6L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(1L: JLong, "bbb", 30L: JLong, hasProcTime = true)))
+
+    // register cleanup timer with 6001
+    testHarness.setProcessingTime(3001)
+    testHarness.processElement(new StreamRecord(
+      binaryRow(2L: JLong, "aaa", 7L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(2L: JLong, "aaa", 8L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(2L: JLong, "aaa", 9L: JLong, hasProcTime = true)))
+
+    // trigger cleanup timer and register cleanup timer with 9002
+    testHarness.setProcessingTime(6002)
+    testHarness.processElement(new StreamRecord(
+      binaryRow(2L: JLong, "aaa", 10L: JLong, hasProcTime = true)))
+    testHarness.processElement(new StreamRecord(
+      binaryRow(2L: JLong, "bbb", 40L: JLong, hasProcTime = true)))
+
+    val result = testHarness.getOutput
+
+    val expectedOutput = new ConcurrentLinkedQueue[Object]()
+
+    expectedOutput.add(new StreamRecord(
+      GenericRow.of(1L: JLong, fromString("aaa"), 1L: JLong, null, 1L: JLong, 1L: JLong)))
 
 Review comment:
   I think we can simplify this to `expectedOutput.add(baserow(1L, "aaa", 1L, null, 1L, 1L))`
which uses `StreamRecordUtils.baserow` static util method.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message