You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/09/08 03:01:54 UTC

[GitHub] [dolphinscheduler] EricGao888 commented on a diff in pull request #10869: [Improvement][SQL Task]use default sql segment separator

EricGao888 commented on code in PR #10869:
URL: https://github.com/apache/dolphinscheduler/pull/10869#discussion_r965456605


##########
docs/docs/zh/guide/task/sql.md:
##########
@@ -19,9 +19,7 @@ SQL任务类型,用于连接数据库并执行相应SQL。
 - sql类型:支持查询和非查询两种。
   - 查询:支持 `DML select` 类型的命令,是有结果集返回的,可以指定邮件通知为表格、附件或表格附件三种模板;
   - 非查询:支持 `DDL`全部命令 和 `DML update、delete、insert` 三种类型的命令;
-    - 分段执行符号:提供在数据源不支持一次执行多段SQL语句时,拆分SQL语句的符号来进行多次调用数据源执行方法。
-    例子:1.当数据源选择Hive数据源时,不需要填写此参数。因为Hive数据源本身支持一次执行多段SQL语句;
-         2.当数据源选择MySQL数据源时,并且要执行多段SQL语句时,需要填写此参数为分号 `;`。因为MySQL数据源不支持一次执行多段SQL语句;
+    - 默认采用`;\n`作为SQL分隔符,拆分成多段SQL语句执行,Hive支持一次执行多段SQL语句,故不会拆分。

Review Comment:
   BWT, could you please update the corresponding English docs?



##########
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/DbType.java:
##########
@@ -74,4 +74,12 @@ public static DbType ofName(String name) {
     public boolean isHive() {
         return this == DbType.HIVE;
     }
+
+    /**
+     * support execute multiple segmented statements at a time
+     * @return
+     */
+    public boolean isSupportMultipleStatement() {
+        return isHive() || this == DbType.SPARK;

Review Comment:
   Since we use `isHive()` here, what about adding a method `isSpark()` and using it here for consistency?



##########
docs/docs/zh/guide/task/sql.md:
##########
@@ -19,9 +19,7 @@ SQL任务类型,用于连接数据库并执行相应SQL。
 - sql类型:支持查询和非查询两种。
   - 查询:支持 `DML select` 类型的命令,是有结果集返回的,可以指定邮件通知为表格、附件或表格附件三种模板;
   - 非查询:支持 `DDL`全部命令 和 `DML update、delete、insert` 三种类型的命令;
-    - 分段执行符号:提供在数据源不支持一次执行多段SQL语句时,拆分SQL语句的符号来进行多次调用数据源执行方法。
-    例子:1.当数据源选择Hive数据源时,不需要填写此参数。因为Hive数据源本身支持一次执行多段SQL语句;
-         2.当数据源选择MySQL数据源时,并且要执行多段SQL语句时,需要填写此参数为分号 `;`。因为MySQL数据源不支持一次执行多段SQL语句;
+    - 默认采用`;\n`作为SQL分隔符,拆分成多段SQL语句执行,Hive支持一次执行多段SQL语句,故不会拆分。

Review Comment:
   ```suggestion
       - 默认采用`;\n`作为SQL分隔符,拆分成多段SQL语句执行。由于Hive支持一次执行多段SQL语句,故不会拆分。
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java:
##########
@@ -133,8 +140,11 @@ public void handle() throws TaskException {
                     DbType.valueOf(sqlParameters.getType()),
                     sqlTaskExecutionContext.getConnectionParams());
 
+            if (DbType.valueOf(sqlParameters.getType()).isSupportMultipleStatement()) {
+                sqlSeparator = "";

Review Comment:
   We could have something like `private static final String HIVE_SQL_SEPARATOR = ""` and put it with other separators on top of the class for better code maintainability.



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org