This is an automated email from the ASF dual-hosted git repository.
lgcareer pushed a commit to branch dev-1.3.0
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev-1.3.0 by this push:
new 6d0375e fix sql task bug #2739 (#2741)
6d0375e is described below
commit 6d0375e46d07f386125a3c6e091e605a515df03d
Author: zixi0825 <[email protected]>
AuthorDate: Thu May 21 16:09:36 2020 +0800
fix sql task bug #2739 (#2741)
* Solve the failure to execute non-query sql
* fix sql task bug
Co-authored-by: sunchaohe <[email protected]>
Co-authored-by: qiaozhanwei <[email protected]>
Co-authored-by: lgcareer <[email protected]>
---
.../dolphinscheduler/common/utils/ParameterUtils.java | 15 ++++++++-------
.../dolphinscheduler/server/worker/task/sql/SqlTask.java | 2 +-
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
index 270e0c4..bbc8955 100644
---
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
+++
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
@@ -213,27 +213,28 @@ public class ParameterUtils {
return inputString;
}
+
/**
- * new
- * $[yyyyMMdd] replace scheduler time
+ * $[yyyyMMdd] replace schedule time
* @param text
- * @param paramsMap
+ * @param scheduleTime
* @return
*/
- public static String replaceScheduleTime(String text, Date scheduleTime,
Map<String, Property> paramsMap) {
- if (paramsMap != null) {
+ public static String replaceScheduleTime(String text, Date scheduleTime) {
+ Map<String, Property> paramsMap = new HashMap<>();
//if getScheduleTime null ,is current date
if (null == scheduleTime) {
scheduleTime = new Date();
}
+
String dateTime =
org.apache.dolphinscheduler.common.utils.DateUtils.format(scheduleTime,
Constants.PARAMETER_FORMAT_TIME);
Property p = new Property();
p.setValue(dateTime);
p.setProp(Constants.PARAMETER_SHECDULE_TIME);
paramsMap.put(Constants.PARAMETER_SHECDULE_TIME, p);
text = ParameterUtils.convertParameterPlaceholders2(text,
convert(paramsMap));
- }
- return text;
+
+ return text;
}
diff --git
a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java
b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java
index ccd4bb2..c62364e 100644
---
a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java
+++
b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java
@@ -179,7 +179,7 @@ public class SqlTask extends AbstractTask {
}
//new
//replace variable TIME with $[YYYYmmddd...] in sql when history run
job and batch complement job
- sql = ParameterUtils.replaceScheduleTime(sql,
taskExecutionContext.getScheduleTime(), paramsMap);
+ sql = ParameterUtils.replaceScheduleTime(sql,
taskExecutionContext.getScheduleTime());
// special characters need to be escaped, ${} needs to be escaped
String rgex = "['\"]*\\$\\{(.*?)\\}['\"]*";
setSqlParamsMap(sql, rgex, sqlParamsMap, paramsMap);