rickchengx commented on code in PR #14527:
URL: 
https://github.com/apache/dolphinscheduler/pull/14527#discussion_r1264792036


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTask.java:
##########
@@ -195,9 +198,29 @@ private List<String> populateSparkOptions() {
         }
 
         // bin/spark-sql -f fileName
+        String sqlContent = "";
+        String resourceFileName = "";
         if (ProgramType.SQL == programType) {
             args.add(SparkConstants.SQL_FROM_FILE);
-            args.add(generateScriptFile());
+            if 
(SparkConstants.TYPE_FILE.equals(sparkParameters.getSqlExecutionType())) {
+                final List<ResourceInfo> resourceInfos = 
sparkParameters.getResourceList();
+                if (resourceInfos.size() > 1) {
+                    log.warn("more than 1 files detected, use the first one by 
default");
+                }
+
+                try {
+                    resourceFileName = resourceInfos.get(0).getResourceName();
+                    sqlContent = FileUtils.readFileToString(
+                            new File(String.format("%s/%s", 
taskExecutionContext.getExecutePath(), resourceFileName)),
+                            StandardCharsets.UTF_8);

Review Comment:
   I don't think so. Since the sql content needs to be further processed, like 
`replaceParam()` in `generateScriptFile()`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to