dianfu commented on code in PR #29048:
URL: https://github.com/apache/flink/pull/29048#discussion_r4310101929


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/rules/logical/PythonCorrelateSplitConcurrencyRule.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.rules.logical;
+
+import org.apache.flink.table.functions.python.PythonFunctionKind;
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalCorrelate;
+import 
org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableFunctionScan;
+import org.apache.flink.table.planner.plan.utils.AsyncUtil;
+import org.apache.flink.table.planner.plan.utils.PythonUtil;
+
+import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.plan.RelRule;
+import org.apache.calcite.rex.RexNode;
+import org.immutables.value.Value;
+
+/** Extracts scalar calls whose concurrency conflicts with their Python 
correlate. */
[email protected]
+public class PythonCorrelateSplitConcurrencyRule
+        extends RelRule<PythonCorrelateSplitConcurrencyRule.Config> {
+
+    public static final PythonCorrelateSplitConcurrencyRule INSTANCE = 
Config.DEFAULT.toRule();
+
+    private PythonCorrelateSplitConcurrencyRule(Config config) {
+        super(config);
+    }
+
+    @Override
+    public boolean matches(RelOptRuleCall call) {
+        final FlinkLogicalTableFunctionScan scan =
+                RemoteCorrelateSplitRule.getTableFunctionScan(call.rel(0));
+        if (scan == null) {
+            return false;
+        }
+        final RexNode invocation = scan.getCall();
+        return PythonUtil.isPythonCall(invocation, PythonFunctionKind.GENERAL)
+                && !PythonUtil.containsPythonCall(invocation, 
PythonFunctionKind.PANDAS)
+                && !PythonUtil.containsPythonCall(invocation, 
PythonFunctionKind.ARROW)
+                && !AsyncUtil.containsAsyncCall(invocation)

Review Comment:
   It skips concurrency splitting whenever an async call is present. For 
example, with f3 and f5 configured with concurrency 3 and 5:
   
   LATERAL TABLE(tf(f3(async_func(a, b), b), f5(a, b)))
   
   The async call is extracted by a later rule, but concurrency splitting is 
not rerun. This leaves f3 and f5 in the same correlate, causing explainSql to 
fail with a concurrency conflict.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to