You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/01/13 05:37:23 UTC

[GitHub] [flink] godfreyhe opened a new pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

godfreyhe opened a new pull request #14625:
URL: https://github.com/apache/flink/pull/14625


   ## What is the purpose of the change
   
   *Separate the implementation of StreamExecMatch*
   
   
   ## Brief change log
   
     - *Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode*
   
   ## Verifying this change
   
   This change is a refactoring rework covered by existing tests.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / **not documented**)
   


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot commented on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759222713


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * fdf9c3005c53149eb7be9501c3c451c4e5cb77e5 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759222713


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963",
       "triggerID" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "af83d032e2bd478541c9fa548866ce398888318f",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12022",
       "triggerID" : "af83d032e2bd478541c9fa548866ce398888318f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * fdf9c3005c53149eb7be9501c3c451c4e5cb77e5 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963) 
   * af83d032e2bd478541c9fa548866ce398888318f Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12022) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759222713


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963",
       "triggerID" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * fdf9c3005c53149eb7be9501c3c451c4e5cb77e5 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759222713


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963",
       "triggerID" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "af83d032e2bd478541c9fa548866ce398888318f",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "af83d032e2bd478541c9fa548866ce398888318f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * fdf9c3005c53149eb7be9501c3c451c4e5cb77e5 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963) 
   * af83d032e2bd478541c9fa548866ce398888318f UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759222713


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963",
       "triggerID" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "af83d032e2bd478541c9fa548866ce398888318f",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12022",
       "triggerID" : "af83d032e2bd478541c9fa548866ce398888318f",
       "triggerType" : "PUSH"
     }, {
       "hash" : "fb5523f600966116a42b3c486a3a2209b6bdec73",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "fb5523f600966116a42b3c486a3a2209b6bdec73",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * af83d032e2bd478541c9fa548866ce398888318f Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12022) 
   * fb5523f600966116a42b3c486a3a2209b6bdec73 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759218410


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit fb5523f600966116a42b3c486a3a2209b6bdec73 (Fri May 28 07:07:56 UTC 2021)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


-- 
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



[GitHub] [flink] flinkbot edited a comment on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759222713


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963",
       "triggerID" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * fdf9c3005c53149eb7be9501c3c451c4e5cb77e5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759222713


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963",
       "triggerID" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "af83d032e2bd478541c9fa548866ce398888318f",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12022",
       "triggerID" : "af83d032e2bd478541c9fa548866ce398888318f",
       "triggerType" : "PUSH"
     }, {
       "hash" : "fb5523f600966116a42b3c486a3a2209b6bdec73",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12061",
       "triggerID" : "fb5523f600966116a42b3c486a3a2209b6bdec73",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * af83d032e2bd478541c9fa548866ce398888318f Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12022) 
   * fb5523f600966116a42b3c486a3a2209b6bdec73 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12061) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759222713


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963",
       "triggerID" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "af83d032e2bd478541c9fa548866ce398888318f",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12022",
       "triggerID" : "af83d032e2bd478541c9fa548866ce398888318f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * af83d032e2bd478541c9fa548866ce398888318f Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12022) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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



[GitHub] [flink] wenlong88 commented on a change in pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
wenlong88 commented on a change in pull request #14625:
URL: https://github.com/apache/flink/pull/14625#discussion_r556995228



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecMatch.java
##########
@@ -0,0 +1,453 @@
+/*
+ * 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.planner.plan.nodes.exec.stream;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.cep.EventComparator;
+import org.apache.flink.cep.nfa.aftermatch.AfterMatchSkipStrategy;
+import org.apache.flink.cep.nfa.compiler.NFACompiler;
+import org.apache.flink.cep.operator.CepOperator;
+import org.apache.flink.cep.pattern.Pattern;
+import org.apache.flink.cep.pattern.Quantifier;
+import org.apache.flink.cep.pattern.conditions.BooleanConditions;
+import org.apache.flink.cep.pattern.conditions.IterativeCondition;
+import org.apache.flink.streaming.api.operators.ProcessOperator;
+import org.apache.flink.streaming.api.transformations.OneInputTransformation;
+import org.apache.flink.streaming.api.windowing.time.Time;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.planner.codegen.CodeGenUtils;
+import org.apache.flink.table.planner.codegen.CodeGeneratorContext;
+import org.apache.flink.table.planner.codegen.MatchCodeGenerator;
+import org.apache.flink.table.planner.codegen.sort.ComparatorCodeGenerator;
+import org.apache.flink.table.planner.delegation.PlannerBase;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecEdge;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeBase;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.MatchSpec;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.SortSpec;
+import org.apache.flink.table.planner.plan.utils.KeySelectorUtil;
+import org.apache.flink.table.planner.plan.utils.RexDefaultVisitor;
+import org.apache.flink.table.planner.utils.JavaScalaConversionUtil;
+import org.apache.flink.table.runtime.generated.GeneratedRecordComparator;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.operators.match.PatternProcessFunctionRunner;
+import org.apache.flink.table.runtime.operators.match.RowDataEventComparator;
+import org.apache.flink.table.runtime.operators.match.RowtimeProcessFunction;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.runtime.typeutils.TypeCheckUtils;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.table.types.logical.TimestampType;
+import org.apache.flink.util.MathUtils;
+
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexLiteral;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.SqlMatchRecognize;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.type.SqlTypeFamily;
+import org.apache.calcite.tools.RelBuilder;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Optional;
+
+/** Stream {@link ExecNode} which matches along with LogicalMatch. */
+public class StreamExecMatch extends ExecNodeBase<RowData> implements StreamExecNode<RowData> {
+
+    private final MatchSpec matchSpec;
+
+    public StreamExecMatch(
+            MatchSpec matchSpec, ExecEdge inputEdge, RowType outputType, String description) {
+        super(Collections.singletonList(inputEdge), outputType, description);
+        this.matchSpec = matchSpec;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected Transformation<RowData> translateToPlanInternal(PlannerBase planner) {
+        final TableConfig config = planner.getTableConfig();
+        final ExecNode<RowData> inputNode = (ExecNode<RowData>) getInputNodes().get(0);
+        final Transformation<RowData> inputTransform = inputNode.translateToPlan(planner);
+        final RowType inputRowType = (RowType) inputNode.getOutputType();
+
+        checkOrderKeys(inputRowType);
+        final EventComparator<RowData> eventComparator =
+                createEventComparator(config, inputRowType);
+        final Transformation<RowData> timestampedInputTransform =
+                translateOrder(inputTransform, inputRowType);
+
+        final Tuple2<Pattern<RowData, RowData>, List<String>> cepPatternAndNames =
+                translatePattern(matchSpec, config, planner.getRelBuilder(), inputRowType);
+        final Pattern<RowData, RowData> cepPattern = cepPatternAndNames.f0;
+
+        // TODO remove this once it is supported in CEP library
+        if (NFACompiler.canProduceEmptyMatches(cepPattern)) {
+            throw new TableException(
+                    "Patterns that can produce empty matches are not supported. There must be at least one non-optional state.");
+        }
+
+        // TODO remove this once it is supported in CEP library
+        if (cepPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY)) {
+            throw new TableException(
+                    "Greedy quantifiers are not allowed as the last element of a Pattern yet. "
+                            + "Finish your pattern with either a simple variable or reluctant quantifier.");
+        }
+
+        if (matchSpec.isAllRows()) {
+            throw new TableException("All rows per match mode is not supported yet.");
+        }
+
+        final int[] partitionKeys = matchSpec.getPartition().getFieldIndices();
+        final SortSpec.SortFieldSpec timeOrderField = matchSpec.getOrderKeys().getFieldSpec(0);
+        final LogicalType timeOrderFieldType =
+                inputRowType.getTypeAt(timeOrderField.getFieldIndex());
+
+        final boolean isProctime = TypeCheckUtils.isProcTime(timeOrderFieldType);
+        final InternalTypeInfo<RowData> inputTypeInfo =
+                (InternalTypeInfo<RowData>) inputTransform.getOutputType();
+        final TypeSerializer<RowData> inputSerializer =
+                inputTypeInfo.createSerializer(planner.getExecEnv().getConfig());
+        final NFACompiler.NFAFactory<RowData> nfaFactory =
+                NFACompiler.compileFactory(cepPattern, false);
+        final MatchCodeGenerator generator =
+                new MatchCodeGenerator(
+                        new CodeGeneratorContext(config),
+                        planner.getRelBuilder(),
+                        false, // nullableInput
+                        JavaScalaConversionUtil.toScala(cepPatternAndNames.f1),
+                        JavaScalaConversionUtil.toScala(Optional.empty()),
+                        CodeGenUtils.DEFAULT_COLLECTOR_TERM());
+        generator.bindInput(
+                inputRowType,
+                CodeGenUtils.DEFAULT_INPUT1_TERM(),
+                JavaScalaConversionUtil.toScala(Optional.empty()));
+        final PatternProcessFunctionRunner patternProcessFunction =
+                generator.generateOneRowPerMatchExpression(
+                        (RowType) getOutputType(), partitionKeys, matchSpec.getMeasures());
+        final CepOperator<RowData, RowData, RowData> operator =
+                new CepOperator<>(
+                        inputSerializer,
+                        isProctime,
+                        nfaFactory,
+                        eventComparator,
+                        cepPattern.getAfterMatchSkipStrategy(),
+                        patternProcessFunction,
+                        null);
+        final OneInputTransformation<RowData, RowData> transform =
+                new OneInputTransformation<>(
+                        timestampedInputTransform,
+                        getDesc(),
+                        operator,
+                        InternalTypeInfo.of(getOutputType()),
+                        timestampedInputTransform.getParallelism());
+        final RowDataKeySelector selector =
+                KeySelectorUtil.getRowDataSelector(partitionKeys, inputTypeInfo);
+        transform.setStateKeySelector(selector);
+        transform.setStateKeyType(selector.getProducedType());
+
+        if (inputsContainSingleton()) {
+            transform.setParallelism(1);
+            transform.setMaxParallelism(1);
+        }
+        return transform;
+    }
+
+    private void checkOrderKeys(RowType inputRowType) {
+        SortSpec orderKeys = matchSpec.getOrderKeys();
+        if (orderKeys.getFieldIndices().length == 0) {

Review comment:
       use orderKeys.getFieldSize() == 0 ?  




----------------------------------------------------------------
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



[GitHub] [flink] flinkbot commented on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759218410


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit fdf9c3005c53149eb7be9501c3c451c4e5cb77e5 (Wed Jan 13 05:39:49 UTC 2021)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #14625: [FLINK-20941][table-planner-blink] Introduce StreamPhysicalMatch, and make StreamExecMatch only extended from ExecNode

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #14625:
URL: https://github.com/apache/flink/pull/14625#issuecomment-759222713


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=11963",
       "triggerID" : "fdf9c3005c53149eb7be9501c3c451c4e5cb77e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "af83d032e2bd478541c9fa548866ce398888318f",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12022",
       "triggerID" : "af83d032e2bd478541c9fa548866ce398888318f",
       "triggerType" : "PUSH"
     }, {
       "hash" : "fb5523f600966116a42b3c486a3a2209b6bdec73",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12061",
       "triggerID" : "fb5523f600966116a42b3c486a3a2209b6bdec73",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * fb5523f600966116a42b3c486a3a2209b6bdec73 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12061) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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