Skip to content

Commit 339881a

Browse files
authored
[Fix-13814] [Built-in variable] shell task transfer param (#13974)
1 parent f801eb3 commit 339881a

File tree

2 files changed

+6
-5
lines changed
  • dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser
  • dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql

2 files changed

+6
-5
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static Map<String, Property> convert(TaskRequest taskExecutionContext, Ab
6969

7070
Map<String, Property> varParams = parameters.getVarPoolMap();
7171

72-
if (MapUtils.isEmpty(globalParams) && MapUtils.isEmpty(localParams)) {
72+
if (MapUtils.isEmpty(globalParams) && MapUtils.isEmpty(localParams) && MapUtils.isEmpty(varParams)) {
7373
return null;
7474
}
7575
// if it is a complement,
@@ -98,7 +98,9 @@ public static Map<String, Property> convert(TaskRequest taskExecutionContext, Ab
9898
convertedParams = localParams;
9999
}
100100
if (varParams != null) {
101-
varParams.putAll(globalParams);
101+
if (globalParams != null) {
102+
varParams.putAll(globalParams);
103+
}
102104
globalParams = varParams;
103105
for (Map.Entry<String, Property> entry : varParams.entrySet()) {
104106
convertedParams.put(entry.getKey(), entry.getValue());

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ private SqlBinds getSqlAndSqlParamsMap(String sql) {
436436
Map<Integer, Property> sqlParamsMap = new HashMap<>();
437437
StringBuilder sqlBuilder = new StringBuilder();
438438

439+
//replace variable TIME with $[YYYYmmddd...] in sql when history run job and batch complement job
440+
sql = ParameterUtils.replaceScheduleTime(sql, taskExecutionContext.getScheduleTime());
439441
// combining local and global parameters
440442
Map<String, Property> paramsMap = ParamUtils.convert(taskExecutionContext, getParameters());
441443

@@ -452,9 +454,6 @@ private SqlBinds getSqlAndSqlParamsMap(String sql) {
452454
sqlParameters.setTitle(title);
453455
}
454456

455-
//new
456-
//replace variable TIME with $[YYYYmmddd...] in sql when history run job and batch complement job
457-
sql = ParameterUtils.replaceScheduleTime(sql, taskExecutionContext.getScheduleTime());
458457
// special characters need to be escaped, ${} needs to be escaped
459458
setSqlParamsMap(sql, rgex, sqlParamsMap, paramsMap,taskExecutionContext.getTaskInstanceId());
460459
//Replace the original value in sql !{...} ,Does not participate in precompilation

0 commit comments

Comments
 (0)