Skip to content

Commit

Permalink
[dataquality] Fix task commnd null bug (apache#9974)
Browse files Browse the repository at this point in the history
  • Loading branch information
zixi0825 authored May 15, 2022
1 parent 2423fa5 commit 359cbe2
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.ArgsUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
import org.apache.dolphinscheduler.plugin.task.dq.rule.RuleManager;
import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.DataQualityConfiguration;
import org.apache.dolphinscheduler.plugin.task.dq.utils.spark.SparkArgsUtils;
Expand All @@ -52,6 +53,7 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -160,19 +162,22 @@ protected String buildCommand() {
List<String> args = new ArrayList<>();

args.add(SPARK2_COMMAND);

// other parameters
args.addAll(SparkArgsUtils.buildArgs(dataQualityParameters.getSparkParameters()));

// replace placeholder
Map<String, Property> paramsMap = ParamUtils.convert(dqTaskExecutionContext,getParameters());

String command = null;

if (null != paramsMap) {
command = ParameterUtils.convertParameterPlaceholders(String.join(" ", args), ParamUtils.convert(paramsMap));
if (MapUtils.isEmpty(paramsMap)) {
paramsMap = new HashMap<>();
}

if (MapUtils.isNotEmpty(dqTaskExecutionContext.getParamsMap())) {
paramsMap.putAll(dqTaskExecutionContext.getParamsMap());
}

command = ParameterUtils.convertParameterPlaceholders(String.join(" ", args), ParamUtils.convert(paramsMap));
logger.info("data quality task command: {}", command);

return command;
Expand All @@ -181,8 +186,8 @@ protected String buildCommand() {
@Override
protected void setMainJarName() {
ResourceInfo mainJar = new ResourceInfo();
String basePath = System.getProperty("user.dir").replace(File.separator + "bin", File.separator + "libs");
mainJar.setRes(basePath + File.separator + CommonUtils.getDataQualityJarName());
String basePath = System.getProperty("user.dir").replace(File.separator + "bin", "");
mainJar.setRes(basePath + File.separator + "libs" + File.separator + CommonUtils.getDataQualityJarName());
dataQualityParameters.getSparkParameters().setMainJar(mainJar);
}

Expand Down

0 comments on commit 359cbe2

Please sign in to comment.