flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] twalthr commented on a change in pull request #6815: [FLINK-7062][cep][table] Added basic support for MATCH_RECOGNIZE
Date Thu, 18 Oct 2018 08:01:34 GMT
twalthr commented on a change in pull request #6815:  [FLINK-7062][cep][table] Added basic
support for MATCH_RECOGNIZE
URL: https://github.com/apache/flink/pull/6815#discussion_r225904709
 
 

 ##########
 File path: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/nodes/MatchRecognize.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.plan.nodes
+
+import com.google.common.collect.ImmutableMap
+import org.apache.calcite.rel.{RelCollation, RelWriter}
+import org.apache.calcite.rex.{RexCall, RexLiteral, RexNode}
+import org.apache.calcite.sql.SqlKind
+import org.apache.calcite.sql.SqlMatchRecognize.AfterOption
+import org.apache.flink.cep.nfa.aftermatch.AfterMatchSkipStrategy
+import org.apache.flink.table.plan.nodes.logical.FlinkLogicalMatch
+import org.apache.flink.table.plan.schema.RowSchema
+
+import scala.collection.JavaConverters._
+
+trait MatchRecognize {
+
+  private type JList[T] = java.util.List[T]
+  private type JSortedSet[T] = java.util.SortedSet[T]
+
+  private[flink] def partitionKeysToString(
+    keys: JList[RexNode],
+    schema: RowSchema,
+    expression: (RexNode, List[String], Option[List[RexNode]]) => String
+  ) = keys.asScala.map(k => expression(k, schema.fieldNames.toList, None)).mkString(",
")
+
+  private[flink] def orderingToString(orders: RelCollation, schema: RowSchema) =
+    orders.getFieldCollations.asScala.map {
+    x => schema.relDataType.getFieldList.get(x.getFieldIndex).getName
+  }.mkString(", ")
+
+  private[flink] def measuresDefineToString(
+      measures: ImmutableMap[String, RexNode],
+      schema: RowSchema,
+      expression: (RexNode, List[String], Option[List[RexNode]]) => String) =
+    measures.asScala.map {
+    case (k, v) => s"${expression(v, schema.fieldNames.toList, None)} AS $k"
+  }.mkString(", ")
+
+  private[flink] def rowsPerMatchToString(isAll: Boolean) =
+    if (isAll) "ALL ROWS PER MATCH" else "ONE ROW PER MATCH"
+
+  private[flink] def subsetToString(subset: ImmutableMap[String, JSortedSet[String]]) =
+    subset.asScala.map {
+    case (k, v) => s"$k = (${v.toArray.mkString(", ")})"
+  }.mkString(", ")
+
+  private[flink] def afterMatchToString(
+    after: RexNode,
+    schema: RowSchema,
+    expression: (RexNode, List[String], Option[List[RexNode]]) => String) = after.getKind
match {
+    case SqlKind.SKIP_TO_FIRST => s"SKIP TO FIRST ${
+      expression(after.asInstanceOf[RexCall].operands
 
 Review comment:
   Why do we need this `expression()` method? Isn't the `toString()` of the RexCall enough
here and in the following call?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message