This is an automated email from the ASF dual-hosted git repository.

zhouyao2023 pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new 1bc4fbaaab [Fix][Core] Fix the placeholders cannot pass parameters 
when using complex config (#9800)
1bc4fbaaab is described below

commit 1bc4fbaaab19605733c77b3b86f9fc2e4758e4f3
Author: Leon Yoah <[email protected]>
AuthorDate: Tue Sep 2 20:00:44 2025 +0800

    [Fix][Core] Fix the placeholders cannot pass parameters when using complex 
config (#9800)
---
 .../core/starter/utils/ConfigBuilder.java          |  5 ++
 .../core/starter/utils/ConfigShadeTest.java        | 49 ++++++++++++++++++
 .../resources/config_table_list_variables.conf     | 60 ++++++++++++++++++++++
 3 files changed, 114 insertions(+)

diff --git 
a/seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/utils/ConfigBuilder.java
 
b/seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/utils/ConfigBuilder.java
index b629913fa0..c8458505c9 100644
--- 
a/seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/utils/ConfigBuilder.java
+++ 
b/seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/utils/ConfigBuilder.java
@@ -266,6 +266,11 @@ public class ConfigBuilder {
                                                             
System.getProperty(placeholder),
                                                             null);
                                                 });
+                            } else if (variable instanceof Map) {
+                                processVariablesMap((Map<String, Object>) 
variable);
+                                return variable;
+                            } else if (variable instanceof List) {
+                                return processVariablesList((List<?>) 
variable);
                             }
                             return variable;
                         })
diff --git 
a/seatunnel-core/seatunnel-core-starter/src/test/java/org/apache/seatunnel/core/starter/utils/ConfigShadeTest.java
 
b/seatunnel-core/seatunnel-core-starter/src/test/java/org/apache/seatunnel/core/starter/utils/ConfigShadeTest.java
index 917bc54f24..770170c762 100644
--- 
a/seatunnel-core/seatunnel-core-starter/src/test/java/org/apache/seatunnel/core/starter/utils/ConfigShadeTest.java
+++ 
b/seatunnel-core/seatunnel-core-starter/src/test/java/org/apache/seatunnel/core/starter/utils/ConfigShadeTest.java
@@ -283,6 +283,55 @@ public class ConfigShadeTest {
                 configCheckException.getMessage());
     }
 
+    @Test
+    public void testTableListPlaceholderReplacement() throws 
URISyntaxException {
+        String incOffsetDays = "7";
+        String testValue = "replaced_value";
+
+        List<String> variables = new ArrayList<>();
+        variables.add("inc_offset_days=" + incOffsetDays);
+        variables.add("test_placeholder=" + testValue);
+
+        URL resource = 
ConfigShadeTest.class.getResource("/config_table_list_variables.conf");
+        Assertions.assertNotNull(resource);
+        Config config = ConfigBuilder.of(Paths.get(resource.toURI()), 
variables);
+
+        List<? extends ConfigObject> sourceConfigs = 
config.getObjectList("source");
+        for (ConfigObject configObject : sourceConfigs) {
+            Config sourceConfig = configObject.toConfig();
+
+            // Test 1: Verify table_list placeholder replacement (List<Map>)
+            if (sourceConfig.hasPath("table_list")) {
+                List<? extends ConfigObject> tableList = 
sourceConfig.getObjectList("table_list");
+                for (ConfigObject tableObject : tableList) {
+                    Config tableConfig = tableObject.toConfig();
+                    String query = tableConfig.getString("query");
+                    // Verify that placeholders are replaced correctly
+                    Assertions.assertTrue(
+                            query.contains("sysdate-" + incOffsetDays),
+                            "Query should contain replaced placeholder value: 
" + query);
+                    Assertions.assertFalse(
+                            query.contains("${inc_offset_days}"),
+                            "Query should not contain unreplaced placeholder: 
" + query);
+                }
+            }
+
+            // Test 2: Verify nested List placeholder replacement 
(List<List<String>>)
+            if (sourceConfig.hasPath("nested_list")) {
+                List<List<String>> nestedList =
+                        (List<List<String>>) 
sourceConfig.getAnyRef("nested_list");
+
+                // Verify nested list placeholders
+                Assertions.assertTrue(
+                        nestedList.get(0).contains(testValue),
+                        "Nested list should contain replaced placeholder");
+                Assertions.assertFalse(
+                        nestedList.get(0).contains("${test_placeholder}"),
+                        "Nested list should not contain unreplaced 
placeholder");
+            }
+        }
+    }
+
     @Test
     public void testDecryptAndEncrypt() {
         String encryptUsername = ConfigShadeUtils.encryptOption("base64", 
USERNAME);
diff --git 
a/seatunnel-core/seatunnel-core-starter/src/test/resources/config_table_list_variables.conf
 
b/seatunnel-core/seatunnel-core-starter/src/test/resources/config_table_list_variables.conf
new file mode 100644
index 0000000000..99b7c1a693
--- /dev/null
+++ 
b/seatunnel-core/seatunnel-core-starter/src/test/resources/config_table_list_variables.conf
@@ -0,0 +1,60 @@
+#
+# 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.
+#
+
+env {
+  job.mode = "BATCH"
+  job.name = "seatunnel table list variable test job"
+  parallelism = 1
+}
+
+source {
+  Jdbc {
+    plugin_output = "source_result"
+    url = "jdbc:mysql://192.168.102.101:3306/test"
+    driver = "com.mysql.cj.jdbc.Driver"
+    connection_check_timeout_sec = 100
+    user = root
+    password = "password"
+    table_list = [
+      {
+        table_path = "myoa.km_review_main",
+        query = """
+        select fd_id,sysdate as etl_time
+        from myoa.km_review_main t
+        WHERE GREATEST(fd_last_modified_time, 
doc_create_time)>=TRUNC(sysdate-${inc_offset_days})
+        """
+      },
+      {
+        table_path = "myoa.lbpm_audit_note",
+        query = """
+        select fd_id,fd_notify_type,sysdate as etl_time from 
myoa.lbpm_audit_note t WHERE FD_CREATE_TIME>=TRUNC(sysdate-${inc_offset_days})
+        """
+      }
+    ]
+    # Test nested List with placeholders
+    nested_list = [
+      ["item1", "${test_placeholder}", "item3"],
+      ["nested_item1", "nested_item2"]
+    ]
+  }
+}
+
+sink {
+  Console {
+    plugin_input = "source_result"
+  }
+}

Reply via email to