Hisoka-X commented on code in PR #6387:
URL: https://github.com/apache/seatunnel/pull/6387#discussion_r1512595875
##########
seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/utils/ConfigBuilder.java:
##########
@@ -88,17 +112,30 @@ public static Config of(@NonNull Map<String, Object>
objectMap, boolean isEncryp
return config;
}
- public static Config of(@NonNull ConfigAdapter configAdapter, @NonNull
Path filePath) {
+ public static Config of(
+ @NonNull ConfigAdapter configAdapter, @NonNull Path filePath,
List<String> variables) {
log.info("With config adapter spi {}",
configAdapter.getClass().getName());
try {
Map<String, Object> flattenedMap =
configAdapter.loadConfig(filePath);
Config config = ConfigFactory.parseMap(flattenedMap);
+ if (variables != null) {
+ Map<String, String> map =
+ variables.stream()
+ .filter(Objects::nonNull)
+ .map(variable -> variable.split("=", 2))
+ .filter(pair -> pair.length == 2F)
+ .collect(Collectors.toMap(pair -> pair[0],
pair -> pair[1]));
+ config =
+ config.resolveWith(
+ ConfigFactory.parseMap(map),
+
ConfigResolveOptions.defaults().setAllowUnresolved(true));
Review Comment:
Seem like this part show twice in this file. Could you refactor it with new
method?
##########
seatunnel-examples/seatunnel-spark-connector-v2-example/src/main/java/org/apache/seatunnel/example/spark/v2/SeaTunnelApiExample.java:
##########
@@ -17,16 +17,36 @@
package org.apache.seatunnel.example.spark.v2;
Review Comment:
Please do not touch example module.
##########
seatunnel-examples/seatunnel-spark-connector-v2-example/src/main/java/org/apache/seatunnel/example/spark/v2/SeaTunnelSparkVariablesExample.java:
##########
@@ -19,23 +19,23 @@
import org.apache.seatunnel.common.config.DeployMode;
import org.apache.seatunnel.core.starter.SeaTunnel;
-import org.apache.seatunnel.core.starter.exception.CommandException;
import org.apache.seatunnel.core.starter.spark.args.SparkCommandArgs;
import java.io.FileNotFoundException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Paths;
+import java.util.Collections;
-public class ExampleUtils {
+public class SeaTunnelSparkVariablesExample {
- public static void builder(String configurePath)
- throws FileNotFoundException, URISyntaxException, CommandException
{
+ public static void main(String[] args) throws FileNotFoundException,
URISyntaxException {
+ String configurePath = args.length > 0 ? args[0] :
"/examples/spark.batch.variables.conf";
String configFile = getTestConfigFile(configurePath);
SparkCommandArgs sparkCommandArgs = new SparkCommandArgs();
sparkCommandArgs.setConfigFile(configFile);
sparkCommandArgs.setCheckConfig(false);
- sparkCommandArgs.setVariables(null);
+ sparkCommandArgs.setVariables(Collections.singletonList("intVal=1"));
Review Comment:
Please revert this.
##########
seatunnel-examples/seatunnel-spark-connector-v2-example/src/main/resources/examples/spark.batch.variables.conf:
##########
@@ -0,0 +1,99 @@
+#
Review Comment:
ditto
--
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]