pnowojski commented on a change in pull request #7440:  [FLINK-10591][table] 
Introduced functions to return time attributes from MATCH_RECOGNIZE
URL: https://github.com/apache/flink/pull/7440#discussion_r248653028
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/harness/MatchHarnessTest.scala
 ##########
 @@ -0,0 +1,97 @@
+/*
+ * 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.time.{Instant, ZoneId}
+import java.util.concurrent.ConcurrentLinkedQueue
+
+import org.apache.flink.api.scala._
+import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord
+import org.apache.flink.table.api.TableEnvironment
+import org.apache.flink.table.api.scala._
+import org.apache.flink.table.runtime.types.CRow
+import org.apache.flink.types.Row
+import org.junit.Test
+
+import scala.collection.mutable
+
+class MatchHarnessTest extends HarnessTestBase {
+
+  import RecordBuilder._
+
+  @Test
+  def testAccessingProctime(): Unit = {
+    val env = StreamExecutionEnvironment.getExecutionEnvironment
+    val tEnv = TableEnvironment.getTableEnvironment(env)
+
+    val data = new mutable.MutableList[(Int, String)]
+    val t = env.fromCollection(data).toTable(tEnv, 'id, 'name, 
'proctime.proctime)
+    tEnv.registerTable("MyTable", t)
+
+    val sqlQuery =
+      s"""
+         |SELECT *
+         |FROM MyTable
+         |MATCH_RECOGNIZE (
+         |  ORDER BY proctime
+         |  MEASURES
+         |    MATCH_PROCTIME() as proctime,
+         |    HOUR(MATCH_PROCTIME()) as currentHour
+         |  PATTERN (A)
+         |  DEFINE
+         |    A AS A.name LIKE '%a%'
+         |) AS T
+         |""".stripMargin
+
+    val harness = createHarnessTester[Byte, Row, CRow](
+      tEnv.sqlQuery(sqlQuery).toAppendStream[Row],
+      "GlobalCepOperator")
+    harness.open()
+
+    val expectedOutput = new ConcurrentLinkedQueue[Object]()
+
+    val now = Instant.now()
 
 Review comment:
   I'm a bit concerned that this test might not be fully reproducible/it is not 
fully deterministic - for example it can fail on travis because of some special 
value of `now` that locally was not the same. In this case this is rather a 
minor issue, but generally speaking it's better if tests are fully 
deterministic, or that at least you can reproduce them in the exactly same way 
locally (for example by using random seed that is being printed at the 
beginning of the test).

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


With regards,
Apache Git Services

Reply via email to