diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java index ca8924bc7f..41b94b009f 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java @@ -33,7 +33,7 @@ public class TaskConstants { public static final String FLINK_APPLICATION_REGEX = "JobID \\w+"; - public static final String SETVALUE_REGEX = "[\\$#]\\{setValue\\(([^)]*)\\)}"; + public static final String SETVALUE_REGEX = "[\\$#]\\{setValue\\((.*?)\\)}"; /** * string false diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskTest.java index a7439aef67..9cf407e00f 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskTest.java @@ -38,4 +38,24 @@ public class AbstractTaskTest { Assertions.assertEquals(jobId, str.substring(6)); } + @Test + public void testSetValue() { + Pattern SETVALUE_REGEX = Pattern.compile(TaskConstants.SETVALUE_REGEX); + String line1 = "${setValue(sql=\"INSERT INTO a VALUES (1, 2);\")}"; + String line2 = "${setValue(a=2))}"; + Matcher matcher1 = SETVALUE_REGEX.matcher(line1); + String str1 = null; + if (matcher1.find()) { + str1 = matcher1.group(); + } + String str2 = null; + Matcher matcher2 = SETVALUE_REGEX.matcher(line2); + if (matcher2.find()) { + str2 = matcher2.group(); + } + Assertions.assertNotNull(str1); + Assertions.assertNotNull(str2); + Assertions.assertEquals(str1.length(), line1.length()); + Assertions.assertEquals(str2.length(), line2.length()); + } }