xuyangzhong commented on code in PR #2268:
URL: https://github.com/apache/fluss/pull/2268#discussion_r2744960928


##########
fluss-flink/fluss-flink-2.2/src/test/java/org/apache/fluss/flink/source/Flink22DeltaJoinITCase.java:
##########
@@ -0,0 +1,862 @@
+/*
+ * 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.fluss.flink.source;
+
+import org.apache.fluss.metadata.TablePath;
+import org.apache.fluss.row.InternalRow;
+
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.table.api.config.OptimizerConfigOptions;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CloseableIterator;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static 
org.apache.fluss.flink.source.testutils.FlinkRowAssertionsUtils.assertResultsIgnoreOrder;
+import static org.apache.fluss.flink.utils.FlinkTestBase.writeRows;
+import static org.apache.fluss.testutils.DataTestUtils.row;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** IT case for Delta Join optimization in Flink 2.2. */
+public class Flink22DeltaJoinITCase extends FlinkTableSourceITCase {
+
+    @BeforeEach
+    @Override
+    void before() {
+        super.before();
+        
tEnv.getConfig().set(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM,
 2);
+        // Set FORCE strategy for delta join
+        tEnv.getConfig()
+                .set(
+                        
OptimizerConfigOptions.TABLE_OPTIMIZER_DELTA_JOIN_STRATEGY,
+                        OptimizerConfigOptions.DeltaJoinStrategy.FORCE);
+    }
+
+    /**
+     * Creates a source table with specified schema and options.
+     *
+     * @param tableName the name of the table
+     * @param columns column definitions (e.g., "a1 int, b1 varchar, c1 
bigint, d1 int, e1 bigint")
+     * @param primaryKey primary key columns (e.g., "c1, d1")
+     * @param bucketKey bucket key column (e.g., "c1")
+     * @param streamType stream type: "insert_only" for first_row, "cdc" for 
delete.behavior=IGNORE,
+     *     null for regular (supports deletes)
+     * @param extraOptions additional WITH options (e.g., "'lookup.cache' = 
'partial'"), or null
+     */
+    private void createSource(
+            String tableName,
+            String columns,
+            String primaryKey,
+            String bucketKey,
+            String streamType,
+            String extraOptions) {

Review Comment:
   What about using Map<String, String> instead of String here?
   ```
   private void createSource(
               String tableName,
               String columns,
               String primaryKey,
               String bucketKey,
               String streamType,
               @Nullable Map<String, String> extraOptions) {
           Map<String, String> withOptions = new HashMap<>();
           if (extraOptions != null) {
               withOptions.putAll(extraOptions);
           }
           withOptions.put("connector", "fluss");
           withOptions.put("bucket.key", bucketKey);
   
           ...
   
           tEnv.executeSql(
                   String.format(
                           "create table %s ( %s, primary key (%s) NOT ENFORCED 
) with ( %s )",
                           tableName,
                           columns,
                           primaryKey,
                           withOptions.entrySet().stream()
                                   .map(e -> String.format("'%s' = '%s'", 
e.getKey(), e.getValue()))
                                   .collect(Collectors.joining(", "))));
       }
   ```



##########
fluss-flink/fluss-flink-2.2/src/test/java/org/apache/fluss/flink/source/Flink22DeltaJoinITCase.java:
##########
@@ -0,0 +1,862 @@
+/*
+ * 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.fluss.flink.source;
+
+import org.apache.fluss.metadata.TablePath;
+import org.apache.fluss.row.InternalRow;
+
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.table.api.config.OptimizerConfigOptions;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CloseableIterator;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static 
org.apache.fluss.flink.source.testutils.FlinkRowAssertionsUtils.assertResultsIgnoreOrder;
+import static org.apache.fluss.flink.utils.FlinkTestBase.writeRows;
+import static org.apache.fluss.testutils.DataTestUtils.row;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** IT case for Delta Join optimization in Flink 2.2. */
+public class Flink22DeltaJoinITCase extends FlinkTableSourceITCase {

Review Comment:
   Inheriting from FlinkTableSourceITCase will result in the repeated execution 
of all existing cases within FlinkTableSourceITCase.
   
   What about extending `FlinkTestBase` and 
   ```
   private static final String CATALOG_NAME = "testcatalog";
   
       private StreamTableEnvironment tEnv;
   
       @BeforeEach
       @Override
       public void beforeEach() throws Exception {
           super.beforeEach();
   
           bootstrapServers = 
conn.getConfiguration().get(ConfigOptions.BOOTSTRAP_SERVERS).get(0);
   
           StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
           tEnv = StreamTableEnvironment.create(env);
   
           tEnv.executeSql(
                   String.format(
                           "create catalog %s with ('type' = 'fluss', '%s' = 
'%s')",
                           CATALOG_NAME, BOOTSTRAP_SERVERS.key(), 
bootstrapServers));
           tEnv.executeSql("use catalog " + CATALOG_NAME);
           tEnv.executeSql(String.format("create database if not exists `%s`", 
DEFAULT_DB));
           tEnv.useDatabase(DEFAULT_DB);
   
           // start two jobs for this test: one for DML involving the delta 
join, and the other for DQL
           // to query the results of the sink table
           
tEnv.getConfig().set(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM,
 2);
           // Set FORCE strategy for delta join
           tEnv.getConfig()
                   .set(
                           
OptimizerConfigOptions.TABLE_OPTIMIZER_DELTA_JOIN_STRATEGY,
                           OptimizerConfigOptions.DeltaJoinStrategy.FORCE);
       }
   
   
       @AfterEach
       void after() {
           tEnv.useDatabase(BUILTIN_DATABASE);
           tEnv.executeSql(String.format("drop database `%s` cascade", 
DEFAULT_DB));
       }
   ```



##########
fluss-flink/fluss-flink-2.2/src/test/java/org/apache/fluss/flink/source/Flink22DeltaJoinITCase.java:
##########
@@ -0,0 +1,862 @@
+/*
+ * 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.fluss.flink.source;
+
+import org.apache.fluss.metadata.TablePath;
+import org.apache.fluss.row.InternalRow;
+
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.table.api.config.OptimizerConfigOptions;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CloseableIterator;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static 
org.apache.fluss.flink.source.testutils.FlinkRowAssertionsUtils.assertResultsIgnoreOrder;
+import static org.apache.fluss.flink.utils.FlinkTestBase.writeRows;
+import static org.apache.fluss.testutils.DataTestUtils.row;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** IT case for Delta Join optimization in Flink 2.2. */
+public class Flink22DeltaJoinITCase extends FlinkTableSourceITCase {
+
+    @BeforeEach
+    @Override
+    void before() {
+        super.before();
+        
tEnv.getConfig().set(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM,
 2);
+        // Set FORCE strategy for delta join
+        tEnv.getConfig()
+                .set(
+                        
OptimizerConfigOptions.TABLE_OPTIMIZER_DELTA_JOIN_STRATEGY,
+                        OptimizerConfigOptions.DeltaJoinStrategy.FORCE);
+    }
+
+    /**
+     * Creates a source table with specified schema and options.
+     *
+     * @param tableName the name of the table
+     * @param columns column definitions (e.g., "a1 int, b1 varchar, c1 
bigint, d1 int, e1 bigint")
+     * @param primaryKey primary key columns (e.g., "c1, d1")
+     * @param bucketKey bucket key column (e.g., "c1")
+     * @param streamType stream type: "insert_only" for first_row, "cdc" for 
delete.behavior=IGNORE,
+     *     null for regular (supports deletes)
+     * @param extraOptions additional WITH options (e.g., "'lookup.cache' = 
'partial'"), or null
+     */
+    private void createSource(
+            String tableName,
+            String columns,
+            String primaryKey,
+            String bucketKey,
+            String streamType,
+            String extraOptions) {
+        StringBuilder withOptions = new StringBuilder();
+        withOptions.append("'connector' = 'fluss', ");
+        withOptions.append(String.format("'bucket.key' = '%s'", bucketKey));
+
+        if ("insert_only".equals(streamType)) {

Review Comment:
   Using `string.equals` here feels a bit awkward.  What about including it in 
`extraOptions` when calling from outside?



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