snuyanzin commented on code in PR #29939:
URL: https://github.com/apache/flink/pull/29939#discussion_r4569563284


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/batch/sql/AsyncCalcITCase.java:
##########
@@ -0,0 +1,271 @@
+/*
+ * 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.runtime.batch.sql;
+
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.table.functions.AsyncScalarFunction;
+import org.apache.flink.table.functions.FunctionContext;
+import org.apache.flink.table.functions.TableFunction;
+import org.apache.flink.table.planner.factories.TestValuesTableFactory;
+import org.apache.flink.table.planner.runtime.utils.BatchTestBase;
+import org.apache.flink.types.Row;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.flink.core.testutils.FlinkAssertions.anyCauseMatches;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** IT cases for {@link AsyncScalarFunction} in batch mode. */
+class AsyncCalcITCase extends BatchTestBase {
+
+    private static final int NUM_ROWS = 1000;
+    private static final int SMALL_NUM_ROWS = 100;
+    private static final int RETRY_NUM_ROWS = 10;
+    private static final int MAX_CONCURRENT_OPERATIONS = 50;
+    private static final int ADDEND = 10;
+
+    @BeforeEach
+    @Override
+    public void before() throws Exception {
+        super.before();
+        tEnv().getConfig()
+                .set(
+                        
ExecutionConfigOptions.TABLE_EXEC_ASYNC_SCALAR_MAX_CONCURRENT_OPERATIONS,
+                        MAX_CONCURRENT_OPERATIONS);
+        
tEnv().getConfig().set(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM,
 1);
+        tEnv().createTemporarySystemFunction("delayedAdd", 
DelayedAddTen.class);
+        tEnv().createTemporarySystemFunction("failingAdd", 
FailingAddTen.class);
+        tEnv().createTemporarySystemFunction("twice", Twice.class);
+        FailingAddTen.FAILURES.set(0);
+        FailingAddTen.ATTEMPTS.set(0);
+    }
+
+    private void createTables(int numRows, int sinkParallelism) {
+        final List<Row> data = new ArrayList<>();
+        for (int i = 0; i < numRows; i++) {
+            data.add(Row.of(i));
+        }
+        tEnv().executeSql(
+                        "CREATE TABLE source_t (a INT) WITH ("
+                                + "'connector' = 'values', "
+                                + "'bounded' = 'true', "
+                                + "'data-id' = '"
+                                + TestValuesTableFactory.registerData(data)
+                                + "')");
+        tEnv().executeSql(
+                        "CREATE TABLE sink_t (a INT, b INT) WITH ("
+                                + "'connector' = 'values', "
+                                + "'sink-insert-only' = 'true', "
+                                + "'sink.parallelism' = '"
+                                + sinkParallelism
+                                + "')");
+    }
+
+    @Test
+    void testAsyncCalc() throws Exception {
+        createTables(SMALL_NUM_ROWS, 2);
+        final String query = "SELECT a, delayedAdd(a) FROM source_t";
+        assertThat(tEnv().explainSql(query)).contains("AsyncCalc");

Review Comment:
   any explanation why do we need this?
   why can't we test such things with veriryPlan checking the entire plan 
instead of one word?



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