Browse Source

[Fix-13814] [Built-in variable] shell task transfer param (#13974)

2.0.9-release
Molin Wang 2 years ago committed by GitHub
parent
commit
339881a48e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/ParamUtils.java
  2. 5
      dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java

6
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/ParamUtils.java

@ -69,7 +69,7 @@ public class ParamUtils {
Map<String, Property> varParams = parameters.getVarPoolMap(); Map<String, Property> varParams = parameters.getVarPoolMap();
if (MapUtils.isEmpty(globalParams) && MapUtils.isEmpty(localParams)) { if (MapUtils.isEmpty(globalParams) && MapUtils.isEmpty(localParams) && MapUtils.isEmpty(varParams)) {
return null; return null;
} }
// if it is a complement, // if it is a complement,
@ -98,7 +98,9 @@ public class ParamUtils {
convertedParams = localParams; convertedParams = localParams;
} }
if (varParams != null) { if (varParams != null) {
varParams.putAll(globalParams); if (globalParams != null) {
varParams.putAll(globalParams);
}
globalParams = varParams; globalParams = varParams;
for (Map.Entry<String, Property> entry : varParams.entrySet()) { for (Map.Entry<String, Property> entry : varParams.entrySet()) {
convertedParams.put(entry.getKey(), entry.getValue()); convertedParams.put(entry.getKey(), entry.getValue());

5
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java

@ -436,6 +436,8 @@ public class SqlTask extends AbstractTaskExecutor {
Map<Integer, Property> sqlParamsMap = new HashMap<>(); Map<Integer, Property> sqlParamsMap = new HashMap<>();
StringBuilder sqlBuilder = new StringBuilder(); StringBuilder sqlBuilder = new StringBuilder();
//replace variable TIME with $[YYYYmmddd...] in sql when history run job and batch complement job
sql = ParameterUtils.replaceScheduleTime(sql, taskExecutionContext.getScheduleTime());
// combining local and global parameters // combining local and global parameters
Map<String, Property> paramsMap = ParamUtils.convert(taskExecutionContext, getParameters()); Map<String, Property> paramsMap = ParamUtils.convert(taskExecutionContext, getParameters());
@ -452,9 +454,6 @@ public class SqlTask extends AbstractTaskExecutor {
sqlParameters.setTitle(title); sqlParameters.setTitle(title);
} }
//new
//replace variable TIME with $[YYYYmmddd...] in sql when history run job and batch complement job
sql = ParameterUtils.replaceScheduleTime(sql, taskExecutionContext.getScheduleTime());
// special characters need to be escaped, ${} needs to be escaped // special characters need to be escaped, ${} needs to be escaped
setSqlParamsMap(sql, rgex, sqlParamsMap, paramsMap,taskExecutionContext.getTaskInstanceId()); setSqlParamsMap(sql, rgex, sqlParamsMap, paramsMap,taskExecutionContext.getTaskInstanceId());
//Replace the original value in sql !{...} ,Does not participate in precompilation //Replace the original value in sql !{...} ,Does not participate in precompilation

Loading…
Cancel
Save