Hisoka-X commented on code in PR #6387:
URL: https://github.com/apache/seatunnel/pull/6387#discussion_r1559314986


##########
docs/en/concept/config.md:
##########
@@ -193,6 +193,83 @@ configured with these two parameters, because in 
SeaTunnel, there is a default c
 parameters are not configured, then the generated data from the last module of 
the previous node will be used.
 This is much more convenient when there is only one source.
 
+## Config variable substitution
+
+In config file we can define some variables and replace it in run time. **This 
is only support `hocon` format file**.
+
+```hocon
+source {
+  FakeSource {
+    result_table_name = ${resName}
+    row.num = ${rowNum}
+    string.template = [${strTemplate}]
+    schema = {
+      fields {
+        name = string
+        age = "int"
+      }
+    }
+  }
+}
+
+transform {
+    sql {
+      source_table_name = ${resName}
+      query = "select * from "${resName}" where name = '"${nameVal}"' "
+      result_table_name = "sql"
+    }
+}
+
+sink {
+  Console {
+     source_table_name = sql
+  }
+}
+```
+
+In the above config, i define some variables, like `${rowNum}`, `${resName}`.
+We can replace those parameters with this shell command:
+
+```shell
+./bin/seatunnel.sh -c <this_config_file> -i rowNum=10 -i resName=fake -i 
strTemplate=abc -i nameVal=abc
+```
+
+Then the finial submitted config is:

Review Comment:
   ```suggestion
   Then the final submitted config is:
   ```



##########
seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgsTest.java:
##########
@@ -1,107 +0,0 @@
-/*
- * 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.seatunnel.core.starter.seatunnel.args;
-
-import org.apache.seatunnel.shade.com.typesafe.config.Config;
-import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory;
-import org.apache.seatunnel.shade.com.typesafe.config.ConfigObject;
-import org.apache.seatunnel.shade.com.typesafe.config.ConfigResolveOptions;
-
-import org.apache.seatunnel.core.starter.utils.CommandLineUtils;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Paths;
-import java.util.List;
-
-public class ClientCommandArgsTest {
-    @Test
-    public void testUserDefinedParamsCommand() throws URISyntaxException {
-        int fakeParallelism = 16;
-        String username = "seatunnel=2.3.1";
-        String password = "dsjr42=4wfskahdsd=w1chh";
-        String fakeSourceTable = "fake";
-        String fakeSinkTable = "sink";
-        String list = "[par1=20230829,par2=20230829]";
-        String blankSpace = "2023-12-26 11:30:00";
-        String[] args = {
-            "-c",
-            "/args/user_defined_params.conf",
-            "-e",
-            "local",
-            "-i",
-            "fake_source_table=" + fakeSourceTable,
-            "-i",
-            "fake_parallelism=" + fakeParallelism,
-            "-i",
-            "fake_sink_table=" + fakeSinkTable,
-            "-i",
-            "password=" + password,
-            "-i",
-            "username=" + username,
-            "-i",
-            "blankSpace=" + blankSpace,
-            "-i",
-            "list=" + list,
-            "-i",
-            "sql=" + "\"select a , b from fake_source_table\""

Review Comment:
   We need add test case like this:
   ```
           String username = "seatunnel=2.3.1";
           String password = "dsjr42=4wfskahdsd=w1chh";
           String list = "[par1=20230829,par2=20230829]";
           String blankSpace = "2023-12-26 11:30:00";
           String sql =  "\"select a , b from fake_source_table\""
   ```
   It contains `=`, ` `, `\"` so on



##########
docs/en/concept/config.md:
##########
@@ -193,6 +193,83 @@ configured with these two parameters, because in 
SeaTunnel, there is a default c
 parameters are not configured, then the generated data from the last module of 
the previous node will be used.
 This is much more convenient when there is only one source.
 
+## Config variable substitution
+
+In config file we can define some variables and replace it in run time. **This 
is only support `hocon` format file**.
+
+```hocon
+source {
+  FakeSource {
+    result_table_name = ${resName}
+    row.num = ${rowNum}
+    string.template = [${strTemplate}]
+    schema = {
+      fields {
+        name = string
+        age = "int"
+      }
+    }
+  }
+}
+
+transform {
+    sql {
+      source_table_name = ${resName}
+      query = "select * from "${resName}" where name = '"${nameVal}"' "
+      result_table_name = "sql"
+    }
+}
+
+sink {
+  Console {
+     source_table_name = sql
+  }
+}
+```
+
+In the above config, i define some variables, like `${rowNum}`, `${resName}`.

Review Comment:
   ```suggestion
   In the above config, we define some variables, like `${rowNum}`, 
`${resName}`.
   ```



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