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/15 09:42:00 UTC

[GitHub] [flink] HuangXingBo opened a new pull request #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

HuangXingBo opened a new pull request #14665:
URL: https://github.com/apache/flink/pull/14665


   ## What is the purpose of the change
   
   *This pull request will port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java*
   
   
   ## Brief change log
   
     - *Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java*
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - *Original Tests*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable)
   


----------------------------------------------------------------
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 #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b1df7f6879a63390c8f252db85f8f338a4f29427 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] HuangXingBo commented on pull request #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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


   @dianfu Thanks a lot for the review. I have addressed the comments at the latest commit.


----------------------------------------------------------------
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] dianfu merged pull request #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

Posted by GitBox <gi...@apache.org>.
dianfu merged pull request #14665:
URL: https://github.com/apache/flink/pull/14665


   


----------------------------------------------------------------
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 #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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


   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 23dd7aa78998633facc8b4282443fa4a7816613f (Fri May 28 07:09:51 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 #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12113",
       "triggerID" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "triggerType" : "PUSH"
     }, {
       "hash" : "23dd7aa78998633facc8b4282443fa4a7816613f",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12167",
       "triggerID" : "23dd7aa78998633facc8b4282443fa4a7816613f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b1df7f6879a63390c8f252db85f8f338a4f29427 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12113) 
   * 23dd7aa78998633facc8b4282443fa4a7816613f Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12167) 
   
   <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 #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12113",
       "triggerID" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b1df7f6879a63390c8f252db85f8f338a4f29427 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12113) 
   
   <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 commented on pull request #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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


   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 b1df7f6879a63390c8f252db85f8f338a4f29427 (Fri Jan 15 09:44:04 UTC 2021)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
    * **This pull request references an unassigned [Jira ticket](https://issues.apache.org/jira/browse/FLINK-20858).** According to the [code contribution guide](https://flink.apache.org/contributing/contribute-code.html), tickets need to be assigned before starting with the implementation work.
   
   
   <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] HuangXingBo commented on a change in pull request #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/batch/BatchExecPythonGroupWindowAggregate.java
##########
@@ -0,0 +1,219 @@
+/*
+ * 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.batch;
+
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.memory.ManagedMemoryUseCase;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.transformations.OneInputTransformation;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.functions.python.PythonFunctionInfo;
+import org.apache.flink.table.planner.calcite.FlinkRelBuilder;
+import org.apache.flink.table.planner.codegen.agg.batch.WindowCodeGenerator;
+import org.apache.flink.table.planner.delegation.PlannerBase;
+import org.apache.flink.table.planner.expressions.PlannerProctimeAttribute;
+import org.apache.flink.table.planner.expressions.PlannerRowtimeAttribute;
+import org.apache.flink.table.planner.expressions.PlannerWindowEnd;
+import org.apache.flink.table.planner.expressions.PlannerWindowProperty;
+import org.apache.flink.table.planner.expressions.PlannerWindowStart;
+import org.apache.flink.table.planner.plan.logical.LogicalWindow;
+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.common.CommonExecPythonAggregate;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.CommonPythonUtil;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.logical.RowType;
+
+import org.apache.calcite.rel.core.AggregateCall;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+
+/** Batch [[ExecNode]] for group widow aggregate (Python user defined aggregate function). */
+public class BatchExecPythonGroupWindowAggregate extends CommonExecPythonAggregate
+        implements BatchExecNode<RowData> {
+
+    private static final String ARROW_PYTHON_GROUP_WINDOW_AGGREGATE_FUNCTION_OPERATOR_NAME =
+            "org.apache.flink.table.runtime.operators.python.aggregate.arrow.batch."
+                    + "BatchArrowPythonGroupWindowAggregateFunctionOperator";
+
+    private final int[] grouping;
+    private final int[] groupingSet;
+    private final AggregateCall[] aggCalls;
+    private final LogicalWindow window;
+    private final int inputTimeFieldIndex;
+    private final FlinkRelBuilder.PlannerNamedWindowProperty[] namedWindowProperties;
+
+    public BatchExecPythonGroupWindowAggregate(
+            int[] grouping,
+            int[] groupingSet,
+            AggregateCall[] aggCalls,
+            LogicalWindow window,
+            int inputTimeFieldIndex,
+            FlinkRelBuilder.PlannerNamedWindowProperty[] namedWindowProperties,
+            ExecEdge inputEdge,
+            RowType outputType,
+            String description) {
+        super(inputEdge, outputType, description);
+        this.grouping = grouping;
+        this.groupingSet = groupingSet;
+        this.aggCalls = aggCalls;
+        this.window = window;
+        this.inputTimeFieldIndex = inputTimeFieldIndex;
+        this.namedWindowProperties = namedWindowProperties;
+    }
+
+    @Override
+    protected Transformation<RowData> translateToPlanInternal(PlannerBase planner) {
+        final ExecNode<RowData> inputNode = (ExecNode<RowData>) getInputNodes().get(0);
+        final Transformation<RowData> inputTransform = inputNode.translateToPlan(planner);
+        final RowType inputRowType = (RowType) inputNode.getOutputType();
+        final RowType outputRowType = InternalTypeInfo.of(getOutputType()).toRowType();
+
+        final Tuple2<Long, Long> windowSizeAndSlideSize = WindowCodeGenerator.getWindowDef(window);
+        final TableConfig tableConfig = planner.getTableConfig();
+        final Configuration config = CommonPythonUtil.getConfig(planner.getExecEnv(), tableConfig);
+        int groupBufferLimitSize =
+                config.getInteger(ExecutionConfigOptions.TABLE_EXEC_WINDOW_AGG_BUFFER_SIZE_LIMIT);
+
+        OneInputTransformation<RowData, RowData> transform =
+                createPythonOneInputTransformation(
+                        inputTransform,
+                        inputRowType,
+                        outputRowType,
+                        groupBufferLimitSize,
+                        windowSizeAndSlideSize.f0,
+                        windowSizeAndSlideSize.f1,
+                        config);
+        if (CommonPythonUtil.isPythonWorkerUsingManagedMemory(config)) {
+            transform.declareManagedMemoryUseCaseAtSlotScope(ManagedMemoryUseCase.PYTHON);
+        }
+        return transform;
+    }
+
+    private OneInputTransformation<RowData, RowData> createPythonOneInputTransformation(
+            Transformation<RowData> inputTransform,
+            RowType inputRowType,
+            RowType outputRowType,
+            int maxLimitSize,
+            long windowSize,
+            long slideSize,
+            Configuration config) {
+        int[] namePropertyTypeArray =
+                Arrays.stream(namedWindowProperties)
+                        .mapToInt(
+                                p -> {
+                                    PlannerWindowProperty property = p.property();
+                                    if (property instanceof PlannerWindowStart) {
+                                        return 0;
+                                    }
+                                    if (property instanceof PlannerWindowEnd) {
+                                        return 1;
+                                    }
+                                    if (property instanceof PlannerRowtimeAttribute) {
+                                        return 2;
+                                    }
+                                    if (property instanceof PlannerProctimeAttribute) {

Review comment:
       Good Catch




----------------------------------------------------------------
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] dianfu commented on a change in pull request #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/batch/BatchExecPythonGroupWindowAggregate.java
##########
@@ -0,0 +1,219 @@
+/*
+ * 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.batch;
+
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.memory.ManagedMemoryUseCase;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.transformations.OneInputTransformation;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.functions.python.PythonFunctionInfo;
+import org.apache.flink.table.planner.calcite.FlinkRelBuilder;
+import org.apache.flink.table.planner.codegen.agg.batch.WindowCodeGenerator;
+import org.apache.flink.table.planner.delegation.PlannerBase;
+import org.apache.flink.table.planner.expressions.PlannerProctimeAttribute;
+import org.apache.flink.table.planner.expressions.PlannerRowtimeAttribute;
+import org.apache.flink.table.planner.expressions.PlannerWindowEnd;
+import org.apache.flink.table.planner.expressions.PlannerWindowProperty;
+import org.apache.flink.table.planner.expressions.PlannerWindowStart;
+import org.apache.flink.table.planner.plan.logical.LogicalWindow;
+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.common.CommonExecPythonAggregate;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.CommonPythonUtil;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.logical.RowType;
+
+import org.apache.calcite.rel.core.AggregateCall;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+
+/** Batch [[ExecNode]] for group widow aggregate (Python user defined aggregate function). */
+public class BatchExecPythonGroupWindowAggregate extends CommonExecPythonAggregate
+        implements BatchExecNode<RowData> {
+
+    private static final String ARROW_PYTHON_GROUP_WINDOW_AGGREGATE_FUNCTION_OPERATOR_NAME =
+            "org.apache.flink.table.runtime.operators.python.aggregate.arrow.batch."
+                    + "BatchArrowPythonGroupWindowAggregateFunctionOperator";
+
+    private final int[] grouping;
+    private final int[] groupingSet;
+    private final AggregateCall[] aggCalls;
+    private final LogicalWindow window;
+    private final int inputTimeFieldIndex;
+    private final FlinkRelBuilder.PlannerNamedWindowProperty[] namedWindowProperties;
+
+    public BatchExecPythonGroupWindowAggregate(
+            int[] grouping,
+            int[] groupingSet,
+            AggregateCall[] aggCalls,
+            LogicalWindow window,
+            int inputTimeFieldIndex,
+            FlinkRelBuilder.PlannerNamedWindowProperty[] namedWindowProperties,
+            ExecEdge inputEdge,
+            RowType outputType,
+            String description) {
+        super(inputEdge, outputType, description);
+        this.grouping = grouping;
+        this.groupingSet = groupingSet;
+        this.aggCalls = aggCalls;
+        this.window = window;
+        this.inputTimeFieldIndex = inputTimeFieldIndex;
+        this.namedWindowProperties = namedWindowProperties;
+    }
+
+    @Override
+    protected Transformation<RowData> translateToPlanInternal(PlannerBase planner) {
+        final ExecNode<RowData> inputNode = (ExecNode<RowData>) getInputNodes().get(0);
+        final Transformation<RowData> inputTransform = inputNode.translateToPlan(planner);
+        final RowType inputRowType = (RowType) inputNode.getOutputType();
+        final RowType outputRowType = InternalTypeInfo.of(getOutputType()).toRowType();
+
+        final Tuple2<Long, Long> windowSizeAndSlideSize = WindowCodeGenerator.getWindowDef(window);
+        final TableConfig tableConfig = planner.getTableConfig();
+        final Configuration config = CommonPythonUtil.getConfig(planner.getExecEnv(), tableConfig);
+        int groupBufferLimitSize =
+                config.getInteger(ExecutionConfigOptions.TABLE_EXEC_WINDOW_AGG_BUFFER_SIZE_LIMIT);
+
+        OneInputTransformation<RowData, RowData> transform =
+                createPythonOneInputTransformation(
+                        inputTransform,
+                        inputRowType,
+                        outputRowType,
+                        groupBufferLimitSize,
+                        windowSizeAndSlideSize.f0,
+                        windowSizeAndSlideSize.f1,
+                        config);
+        if (CommonPythonUtil.isPythonWorkerUsingManagedMemory(config)) {
+            transform.declareManagedMemoryUseCaseAtSlotScope(ManagedMemoryUseCase.PYTHON);
+        }
+        return transform;
+    }
+
+    private OneInputTransformation<RowData, RowData> createPythonOneInputTransformation(
+            Transformation<RowData> inputTransform,
+            RowType inputRowType,
+            RowType outputRowType,
+            int maxLimitSize,
+            long windowSize,
+            long slideSize,
+            Configuration config) {
+        int[] namePropertyTypeArray =
+                Arrays.stream(namedWindowProperties)
+                        .mapToInt(
+                                p -> {
+                                    PlannerWindowProperty property = p.property();
+                                    if (property instanceof PlannerWindowStart) {
+                                        return 0;
+                                    }
+                                    if (property instanceof PlannerWindowEnd) {
+                                        return 1;
+                                    }
+                                    if (property instanceof PlannerRowtimeAttribute) {
+                                        return 2;
+                                    }
+                                    if (property instanceof PlannerProctimeAttribute) {

Review comment:
       There is no corresponding code for this in the original Scala class, could you double check that?




----------------------------------------------------------------
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] dianfu commented on a change in pull request #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/batch/BatchExecPythonGroupWindowAggregate.java
##########
@@ -0,0 +1,219 @@
+/*
+ * 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.batch;
+
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.memory.ManagedMemoryUseCase;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.transformations.OneInputTransformation;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.functions.python.PythonFunctionInfo;
+import org.apache.flink.table.planner.calcite.FlinkRelBuilder;
+import org.apache.flink.table.planner.codegen.agg.batch.WindowCodeGenerator;
+import org.apache.flink.table.planner.delegation.PlannerBase;
+import org.apache.flink.table.planner.expressions.PlannerProctimeAttribute;
+import org.apache.flink.table.planner.expressions.PlannerRowtimeAttribute;
+import org.apache.flink.table.planner.expressions.PlannerWindowEnd;
+import org.apache.flink.table.planner.expressions.PlannerWindowProperty;
+import org.apache.flink.table.planner.expressions.PlannerWindowStart;
+import org.apache.flink.table.planner.plan.logical.LogicalWindow;
+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.common.CommonExecPythonAggregate;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.CommonPythonUtil;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.logical.RowType;
+
+import org.apache.calcite.rel.core.AggregateCall;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+
+/** Batch [[ExecNode]] for group widow aggregate (Python user defined aggregate function). */
+public class BatchExecPythonGroupWindowAggregate extends CommonExecPythonAggregate
+        implements BatchExecNode<RowData> {
+
+    private static final String ARROW_PYTHON_GROUP_WINDOW_AGGREGATE_FUNCTION_OPERATOR_NAME =
+            "org.apache.flink.table.runtime.operators.python.aggregate.arrow.batch."
+                    + "BatchArrowPythonGroupWindowAggregateFunctionOperator";
+
+    private final int[] grouping;
+    private final int[] groupingSet;
+    private final AggregateCall[] aggCalls;
+    private final LogicalWindow window;
+    private final int inputTimeFieldIndex;
+    private final FlinkRelBuilder.PlannerNamedWindowProperty[] namedWindowProperties;
+
+    public BatchExecPythonGroupWindowAggregate(
+            int[] grouping,
+            int[] groupingSet,
+            AggregateCall[] aggCalls,
+            LogicalWindow window,
+            int inputTimeFieldIndex,
+            FlinkRelBuilder.PlannerNamedWindowProperty[] namedWindowProperties,
+            ExecEdge inputEdge,
+            RowType outputType,
+            String description) {
+        super(inputEdge, outputType, description);
+        this.grouping = grouping;
+        this.groupingSet = groupingSet;
+        this.aggCalls = aggCalls;
+        this.window = window;
+        this.inputTimeFieldIndex = inputTimeFieldIndex;
+        this.namedWindowProperties = namedWindowProperties;
+    }
+
+    @Override
+    protected Transformation<RowData> translateToPlanInternal(PlannerBase planner) {
+        final ExecNode<RowData> inputNode = (ExecNode<RowData>) getInputNodes().get(0);
+        final Transformation<RowData> inputTransform = inputNode.translateToPlan(planner);
+        final RowType inputRowType = (RowType) inputNode.getOutputType();
+        final RowType outputRowType = InternalTypeInfo.of(getOutputType()).toRowType();
+
+        final Tuple2<Long, Long> windowSizeAndSlideSize = WindowCodeGenerator.getWindowDef(window);
+        final TableConfig tableConfig = planner.getTableConfig();
+        final Configuration config = CommonPythonUtil.getConfig(planner.getExecEnv(), tableConfig);
+        int groupBufferLimitSize =
+                config.getInteger(ExecutionConfigOptions.TABLE_EXEC_WINDOW_AGG_BUFFER_SIZE_LIMIT);
+
+        OneInputTransformation<RowData, RowData> transform =
+                createPythonOneInputTransformation(
+                        inputTransform,
+                        inputRowType,
+                        outputRowType,
+                        groupBufferLimitSize,
+                        windowSizeAndSlideSize.f0,
+                        windowSizeAndSlideSize.f1,
+                        config);
+        if (CommonPythonUtil.isPythonWorkerUsingManagedMemory(config)) {
+            transform.declareManagedMemoryUseCaseAtSlotScope(ManagedMemoryUseCase.PYTHON);
+        }
+        return transform;
+    }
+
+    private OneInputTransformation<RowData, RowData> createPythonOneInputTransformation(
+            Transformation<RowData> inputTransform,
+            RowType inputRowType,
+            RowType outputRowType,
+            int maxLimitSize,
+            long windowSize,
+            long slideSize,
+            Configuration config) {
+        int[] namePropertyTypeArray =
+                Arrays.stream(namedWindowProperties)
+                        .mapToInt(
+                                p -> {
+                                    PlannerWindowProperty property = p.property();
+                                    if (property instanceof PlannerWindowStart) {
+                                        return 0;
+                                    }
+                                    if (property instanceof PlannerWindowEnd) {
+                                        return 1;
+                                    }
+                                    if (property instanceof PlannerRowtimeAttribute) {
+                                        return 2;
+                                    }
+                                    if (property instanceof PlannerProctimeAttribute) {

Review comment:
       There is the corresponding code for this in the original Scala class, could you double check that?




----------------------------------------------------------------
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 #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12113",
       "triggerID" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "triggerType" : "PUSH"
     }, {
       "hash" : "23dd7aa78998633facc8b4282443fa4a7816613f",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12167",
       "triggerID" : "23dd7aa78998633facc8b4282443fa4a7816613f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 23dd7aa78998633facc8b4282443fa4a7816613f Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12167) 
   
   <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 #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12113",
       "triggerID" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "triggerType" : "PUSH"
     }, {
       "hash" : "23dd7aa78998633facc8b4282443fa4a7816613f",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "23dd7aa78998633facc8b4282443fa4a7816613f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b1df7f6879a63390c8f252db85f8f338a4f29427 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12113) 
   * 23dd7aa78998633facc8b4282443fa4a7816613f 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 #14665: [FLINK-20858][python][table-planner-blink] Port StreamExecPythonGroupWindowAggregate and BatchExecPythonGroupWindowAggregate to Java

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12113",
       "triggerID" : "b1df7f6879a63390c8f252db85f8f338a4f29427",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b1df7f6879a63390c8f252db85f8f338a4f29427 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=12113) 
   
   <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