You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dolphinscheduler.apache.org by zx liu <li...@gmail.com> on 2020/09/21 09:09:01 UTC

[DISCUSS] support multi-queries in single sql transformation task #3710

hi all,

The current sql task cannot support multiple queries, but my project is
very emergency about this feature. I chang this  feature  in my local.but
I'm not sure if my change is reasonable, so i need some help or suggestions。

hive and sql use the same code to execute sql,

executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
postStatementSqlBinds, createFuncs);

But the problem here is that hive JDBC does not support multiple queries,
mysql mssql supports multiple queries. If both mysql mssql  and hive
supports multiple queries , so I consider the compatibility of the two
here, and modify it to split the sql statement according to the
conventional ";", but execute them one by one.

// support multiQueries 2020/9/16
String[] sqlsplit = mainSqlBinds.getSql().split(";");
if (sqlsplit.length == 0) {
    logger.error("please check sqlscript can splited by ';'");
    return;
}
Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
for (String sqlscript : sqlsplit) {
    executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
preStatementSqlBinds, postStatementSqlBinds, createFuncs);
}

I don’t know if this change is reasonable, I hope you can give some
reasonable suggestions

https://github.com/apache/incubator-dolphinscheduler/issues/3710

thk!

当前的sql组件支持正常的多条语句同时执行,但是我们项目对这个功能比较着急,我在本地做了修改,但是我不确定我改的是否合理。

希望得到大家的建议或者帮助。

跟踪代码发现,hive 与mysql 使用了同样的执行语句的入口:

executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
postStatementSqlBinds, createFuncs);


有些数据源可能直接在jdbc 的连接参数加上allowmultiqueries=true就可以,但是hive jdbc是不支持 批量sql支持的这个功能,

我的考虑是在不能确定其它的数据源是否也支持多sql查询的功能,所以使用";"分割sql语句依然保持一条一条的语句执行,这样能

保证这两种情况兼容,同样能够实现基本的功能,代码的改动量很少。修改成这样:

// support multiQueries 2020/9/16
String[] sqlsplit = mainSqlBinds.getSql().split(";");
if (sqlsplit.length == 0) {
    logger.error("please check sqlscript can splited by ';'");
    return;
}
Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
for (String sqlscript : sqlsplit) {
    executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
preStatementSqlBinds, postStatementSqlBinds, createFuncs);
}

这样修改是否合理,希望能够给予帮助或者建议。

谢谢! https://github.com/apache/incubator-dolphinscheduler/issues/3710

回复: [DISCUSS] support multi-queries in single sql transformation task #3710

Posted by yongqing <59...@qq.com>.
+1




------------------&nbsp;原始邮件&nbsp;------------------
发件人:                                                                                                                        "dev"                                                                                    <dailidong66@gmail.com&gt;;
发送时间:&nbsp;2020年9月28日(星期一) 下午2:17
收件人:&nbsp;"dev"<dev@dolphinscheduler.apache.org&gt;;

主题:&nbsp;Re: [DISCUSS] support multi-queries in single sql transformation task #3710



very good,&nbsp;&nbsp; ';' is mostly used on many occasions, but as shaoj and boyi
said,&nbsp; I think we should care about the ";" not at the end of the sentence,
how to modify the sql script for user? give user a solution will be
better.&nbsp; what about double ";;" ?&nbsp; please leave message


By the way, don't use picture in mail list, it can't be shown on apache
mailing list
you can upload picture on github, then use pic url replace



Best Regards
---------------
DolphinScheduler(Incubator) PPMC
Lidong Dai 代立冬
dailidong66@gmail.com
---------------


zx liu <liuzx778899@gmail.com&gt; 于2020年9月24日周四 下午8:43写道:

&gt; First of all, yes, executeFuncAndSql is in a loop state, it will frequently close and open connections,
&gt;
&gt; I found that sqltask connect always uses jdbc and DAO modules to have integrated druid, so I think you
&gt;
&gt; can use druid to connect to the database so that you can use the connection pool, it can solve the problem
&gt;
&gt; of frequent opening and closing of connections and improve the efficiency of multiple query connections
&gt;
&gt; [image: image.png]
&gt;
&gt; [image: image.png]
&gt;
&gt; Secondly, for sending mail, it is processed in executeFuncAndSql. In fact, it will be sent once when
&gt; executed once. There is no case that only support mulitiple non-query statement and support only
&gt; one select statement。
&gt;
&gt; [image: image.png]
&gt;
&gt;
&gt; Finally, regarding the';' segmentation, this is based on the habit of executing sqlscript in common
&gt;&nbsp; databases. If the comment exists';', the error reporting mechanism will be executed and the user will
&gt;&nbsp; be prompted to modify sqlscript
&gt;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 首先,是的,executeFuncAndSql处于循环状态,它将频繁关闭和打开连接,我发现sqltask connect始终使用jdbc和DAO模块来集成druid,
&gt; 因此我认为您可以使用druid连接到数据库,因此可以使用连接池,而不是在executeFuncAndSql中执行sql语句前建立数据库连接,同时本次
&gt; 提交的sql语句只连接同一个数据库。可以在执行前就完成数据库的连接。这样就可以解决频繁打开和关闭连接的问题,并提高多个查询连接的效率,
&gt;&nbsp;&nbsp;&nbsp;&nbsp; 其次,对于发送邮件,它在executeFuncAndSql中进行处理。实际上一次执行将发送一次。每一个sql都能发送邮件没有只支持多种非查询语句
&gt; 而仅支持一个select语句的情况。
&gt;&nbsp;&nbsp;&nbsp;&nbsp; 最后,关于';'分割的情况,这是基于常见数据库的执行sqlscript的习惯来决定的。假如注释存在';',执行报错机制,提示使用者修改sqlscript.
&gt; 我认为这样并没有太大的问题。
&gt;
&gt;
&gt; wu shaoj <gabrywu@apache.org&gt; 于2020年9月23日周三 下午6:00写道:
&gt;
&gt;&gt; Yes, don't split with semicolon [";"],
&gt;&gt; So PLEASE DO NOT SUPPORT MULTI SQLS IN SQL TASK !!!
&gt;&gt; We can add a new task, which type is SQL-SCRIPT, to suport the multil dml
&gt;&gt; SQLs, and not support multi query sqls is better
&gt;&gt;
&gt;&gt;
&gt;&gt; On 2020/9/23, 15:30, "boyi" <zhangboyi_mx@163.com&gt; wrote:
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; hi:
&gt;&gt;
&gt;&gt;
&gt;&gt;
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Don't split with semicolon [";"], it's a problem
&gt;&gt;
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; For example, SQL contains comments with semicolons [";"]
&gt;&gt;
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; In this way, there will be problems when the program is executed
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; --------------------------------------
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; BoYi ZhangE-mail : zhangboyi_mx@163.com
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; On 09/23/2020 15:06,lgcareer2019@outlook.com<lgcareer2019@outlook.com&gt;
&gt;&gt; wrote:
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Hi,If execute executeFuncAndSql in a loop,it will close and open
&gt;&gt; connection frequently.
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; You can try use the `addBatch` and `executeBatch` method of
&gt;&gt; PrepareStatement,
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; But it seems hive jdbc didn't support it.
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; BTW,Beacause the sql task can send the result by the email now,So If
&gt;&gt; support multiple queries,How to send the result.
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Whether we only support mulitiple non-query statement and support
&gt;&gt; only one select statement?
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Welcome discuss!Thanks!
&gt;&gt;
&gt;&gt;
&gt;&gt;
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Thanks,
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Gang Li
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; DolphinScheduler(Incubator) PPMC
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Gang Li 李岗
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; lgcareer@apache.org
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; From: zx liu
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Date: 2020-09-21 17:09
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; To: dev
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Subject: [DISCUSS] support multi-queries in single sql transformation
&gt;&gt; task #3710
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; hi all,
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; The current sql task cannot support multiple queries, but my project
&gt;&gt; is
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; very emergency about this feature. I chang this&nbsp; feature&nbsp; in my
&gt;&gt; local.but
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; I'm not sure if my change is reasonable, so i need some help or
&gt;&gt; suggestions。
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; hive and sql use the same code to execute sql,
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; postStatementSqlBinds, createFuncs);
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; But the problem here is that hive JDBC does not support multiple
&gt;&gt; queries,
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; mysql mssql supports multiple queries. If both mysql mssql&nbsp; and hive
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; supports multiple queries , so I consider the compatibility of the two
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; here, and modify it to split the sql statement according to the
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; conventional ";", but execute them one by one.
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; // support multiQueries 2020/9/16
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; String[] sqlsplit = mainSqlBinds.getSql().split(";");
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; if (sqlsplit.length == 0) {
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; logger.error("please check sqlscript can splited by ';'");
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; return;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Map<Integer, Property&gt; sqlParamsMap = mainSqlBinds.getParamsMap();
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; for (String sqlscript : sqlsplit) {
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; preStatementSqlBinds, postStatementSqlBinds, createFuncs);
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; I don’t know if this change is reasonable, I hope you can give some
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; reasonable suggestions
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; https://github.com/apache/incubator-dolphinscheduler/issues/3710
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; thk!
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; 当前的sql组件支持正常的多条语句同时执行,但是我们项目对这个功能比较着急,我在本地做了修改,但是我不确定我改的是否合理。
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; 希望得到大家的建议或者帮助。
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; 跟踪代码发现,hive 与mysql 使用了同样的执行语句的入口:
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; postStatementSqlBinds, createFuncs);
&gt;&gt;
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; 有些数据源可能直接在jdbc 的连接参数加上allowmultiqueries=true就可以,但是hive jdbc是不支持
&gt;&gt; 批量sql支持的这个功能,
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; 我的考虑是在不能确定其它的数据源是否也支持多sql查询的功能,所以使用";"分割sql语句依然保持一条一条的语句执行,这样能
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; 保证这两种情况兼容,同样能够实现基本的功能,代码的改动量很少。修改成这样:
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; // support multiQueries 2020/9/16
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; String[] sqlsplit = mainSqlBinds.getSql().split(";");
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; if (sqlsplit.length == 0) {
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; logger.error("please check sqlscript can splited by ';'");
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; return;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Map<Integer, Property&gt; sqlParamsMap = mainSqlBinds.getParamsMap();
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; for (String sqlscript : sqlsplit) {
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; preStatementSqlBinds, postStatementSqlBinds, createFuncs);
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; 这样修改是否合理,希望能够给予帮助或者建议。
&gt;&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; 谢谢! https://github.com/apache/incubator-dolphinscheduler/issues/3710
&gt;&gt;
&gt;

Re: [DISCUSS] support multi-queries in single sql transformation task #3710

Posted by lidong dai <da...@gmail.com>.
very good,   ';' is mostly used on many occasions, but as shaoj and boyi
said,  I think we should care about the ";" not at the end of the sentence,
how to modify the sql script for user? give user a solution will be
better.  what about double ";;" ?  please leave message


By the way, don't use picture in mail list, it can't be shown on apache
mailing list
you can upload picture on github, then use pic url replace



Best Regards
---------------
DolphinScheduler(Incubator) PPMC
Lidong Dai 代立冬
dailidong66@gmail.com
---------------


zx liu <li...@gmail.com> 于2020年9月24日周四 下午8:43写道:

> First of all, yes, executeFuncAndSql is in a loop state, it will frequently close and open connections,
>
> I found that sqltask connect always uses jdbc and DAO modules to have integrated druid, so I think you
>
> can use druid to connect to the database so that you can use the connection pool, it can solve the problem
>
> of frequent opening and closing of connections and improve the efficiency of multiple query connections
>
> [image: image.png]
>
> [image: image.png]
>
> Secondly, for sending mail, it is processed in executeFuncAndSql. In fact, it will be sent once when
> executed once. There is no case that only support mulitiple non-query statement and support only
> one select statement。
>
> [image: image.png]
>
>
> Finally, regarding the';' segmentation, this is based on the habit of executing sqlscript in common
>  databases. If the comment exists';', the error reporting mechanism will be executed and the user will
>  be prompted to modify sqlscript
>
>      首先,是的,executeFuncAndSql处于循环状态,它将频繁关闭和打开连接,我发现sqltask connect始终使用jdbc和DAO模块来集成druid,
> 因此我认为您可以使用druid连接到数据库,因此可以使用连接池,而不是在executeFuncAndSql中执行sql语句前建立数据库连接,同时本次
> 提交的sql语句只连接同一个数据库。可以在执行前就完成数据库的连接。这样就可以解决频繁打开和关闭连接的问题,并提高多个查询连接的效率,
>     其次,对于发送邮件,它在executeFuncAndSql中进行处理。实际上一次执行将发送一次。每一个sql都能发送邮件没有只支持多种非查询语句
> 而仅支持一个select语句的情况。
>     最后,关于';'分割的情况,这是基于常见数据库的执行sqlscript的习惯来决定的。假如注释存在';',执行报错机制,提示使用者修改sqlscript.
> 我认为这样并没有太大的问题。
>
>
> wu shaoj <ga...@apache.org> 于2020年9月23日周三 下午6:00写道:
>
>> Yes, don't split with semicolon [";"],
>> So PLEASE DO NOT SUPPORT MULTI SQLS IN SQL TASK !!!
>> We can add a new task, which type is SQL-SCRIPT, to suport the multil dml
>> SQLs, and not support multi query sqls is better
>>
>>
>> On 2020/9/23, 15:30, "boyi" <zh...@163.com> wrote:
>>
>>     hi:
>>
>>
>>
>>
>>     Don't split with semicolon [";"], it's a problem
>>
>>
>>     For example, SQL contains comments with semicolons [";"]
>>
>>
>>     In this way, there will be problems when the program is executed
>>     --------------------------------------
>>     BoYi ZhangE-mail : zhangboyi_mx@163.com
>>     On 09/23/2020 15:06,lgcareer2019@outlook.com<lg...@outlook.com>
>> wrote:
>>     Hi,If execute executeFuncAndSql in a loop,it will close and open
>> connection frequently.
>>     You can try use the `addBatch` and `executeBatch` method of
>> PrepareStatement,
>>     But it seems hive jdbc didn't support it.
>>
>>     BTW,Beacause the sql task can send the result by the email now,So If
>> support multiple queries,How to send the result.
>>     Whether we only support mulitiple non-query statement and support
>> only one select statement?
>>
>>     Welcome discuss!Thanks!
>>
>>
>>
>>
>>     Thanks,
>>     Gang Li
>>
>>     DolphinScheduler(Incubator) PPMC
>>     Gang Li 李岗
>>
>>     lgcareer@apache.org
>>
>>     From: zx liu
>>     Date: 2020-09-21 17:09
>>     To: dev
>>     Subject: [DISCUSS] support multi-queries in single sql transformation
>> task #3710
>>     hi all,
>>
>>     The current sql task cannot support multiple queries, but my project
>> is
>>     very emergency about this feature. I chang this  feature  in my
>> local.but
>>     I'm not sure if my change is reasonable, so i need some help or
>> suggestions。
>>
>>     hive and sql use the same code to execute sql,
>>
>>     executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
>>     postStatementSqlBinds, createFuncs);
>>
>>     But the problem here is that hive JDBC does not support multiple
>> queries,
>>     mysql mssql supports multiple queries. If both mysql mssql  and hive
>>     supports multiple queries , so I consider the compatibility of the two
>>     here, and modify it to split the sql statement according to the
>>     conventional ";", but execute them one by one.
>>
>>     // support multiQueries 2020/9/16
>>     String[] sqlsplit = mainSqlBinds.getSql().split(";");
>>     if (sqlsplit.length == 0) {
>>     logger.error("please check sqlscript can splited by ';'");
>>     return;
>>     }
>>     Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
>>     for (String sqlscript : sqlsplit) {
>>     executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
>>     preStatementSqlBinds, postStatementSqlBinds, createFuncs);
>>     }
>>
>>     I don’t know if this change is reasonable, I hope you can give some
>>     reasonable suggestions
>>
>>     https://github.com/apache/incubator-dolphinscheduler/issues/3710
>>
>>     thk!
>>
>>     当前的sql组件支持正常的多条语句同时执行,但是我们项目对这个功能比较着急,我在本地做了修改,但是我不确定我改的是否合理。
>>
>>     希望得到大家的建议或者帮助。
>>
>>     跟踪代码发现,hive 与mysql 使用了同样的执行语句的入口:
>>
>>     executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
>>     postStatementSqlBinds, createFuncs);
>>
>>
>>     有些数据源可能直接在jdbc 的连接参数加上allowmultiqueries=true就可以,但是hive jdbc是不支持
>> 批量sql支持的这个功能,
>>
>>     我的考虑是在不能确定其它的数据源是否也支持多sql查询的功能,所以使用";"分割sql语句依然保持一条一条的语句执行,这样能
>>
>>     保证这两种情况兼容,同样能够实现基本的功能,代码的改动量很少。修改成这样:
>>
>>     // support multiQueries 2020/9/16
>>     String[] sqlsplit = mainSqlBinds.getSql().split(";");
>>     if (sqlsplit.length == 0) {
>>     logger.error("please check sqlscript can splited by ';'");
>>     return;
>>     }
>>     Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
>>     for (String sqlscript : sqlsplit) {
>>     executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
>>     preStatementSqlBinds, postStatementSqlBinds, createFuncs);
>>     }
>>
>>     这样修改是否合理,希望能够给予帮助或者建议。
>>
>>     谢谢! https://github.com/apache/incubator-dolphinscheduler/issues/3710
>>
>

Re: [DISCUSS] support multi-queries in single sql transformation task #3710

Posted by zx liu <li...@gmail.com>.
First of all, yes, executeFuncAndSql is in a loop state, it will
frequently close and open connections,

I found that sqltask connect always uses jdbc and DAO modules to have
integrated druid, so I think you

can use druid to connect to the database so that you can use the
connection pool, it can solve the problem

of frequent opening and closing of connections and improve the
efficiency of multiple query connections

[image: image.png]

[image: image.png]

Secondly, for sending mail, it is processed in executeFuncAndSql. In
fact, it will be sent once when
executed once. There is no case that only support mulitiple non-query
statement and support only
one select statement。

[image: image.png]


Finally, regarding the';' segmentation, this is based on the habit of
executing sqlscript in common
 databases. If the comment exists';', the error reporting mechanism
will be executed and the user will
 be prompted to modify sqlscript

     首先,是的,executeFuncAndSql处于循环状态,它将频繁关闭和打开连接,我发现sqltask
connect始终使用jdbc和DAO模块来集成druid,
因此我认为您可以使用druid连接到数据库,因此可以使用连接池,而不是在executeFuncAndSql中执行sql语句前建立数据库连接,同时本次
提交的sql语句只连接同一个数据库。可以在执行前就完成数据库的连接。这样就可以解决频繁打开和关闭连接的问题,并提高多个查询连接的效率,
    其次,对于发送邮件,它在executeFuncAndSql中进行处理。实际上一次执行将发送一次。每一个sql都能发送邮件没有只支持多种非查询语句
而仅支持一个select语句的情况。
    最后,关于';'分割的情况,这是基于常见数据库的执行sqlscript的习惯来决定的。假如注释存在';',执行报错机制,提示使用者修改sqlscript.
我认为这样并没有太大的问题。


wu shaoj <ga...@apache.org> 于2020年9月23日周三 下午6:00写道:

> Yes, don't split with semicolon [";"],
> So PLEASE DO NOT SUPPORT MULTI SQLS IN SQL TASK !!!
> We can add a new task, which type is SQL-SCRIPT, to suport the multil dml
> SQLs, and not support multi query sqls is better
>
>
> On 2020/9/23, 15:30, "boyi" <zh...@163.com> wrote:
>
>     hi:
>
>
>
>
>     Don't split with semicolon [";"], it's a problem
>
>
>     For example, SQL contains comments with semicolons [";"]
>
>
>     In this way, there will be problems when the program is executed
>     --------------------------------------
>     BoYi ZhangE-mail : zhangboyi_mx@163.com
>     On 09/23/2020 15:06,lgcareer2019@outlook.com<lg...@outlook.com>
> wrote:
>     Hi,If execute executeFuncAndSql in a loop,it will close and open
> connection frequently.
>     You can try use the `addBatch` and `executeBatch` method of
> PrepareStatement,
>     But it seems hive jdbc didn't support it.
>
>     BTW,Beacause the sql task can send the result by the email now,So If
> support multiple queries,How to send the result.
>     Whether we only support mulitiple non-query statement and support only
> one select statement?
>
>     Welcome discuss!Thanks!
>
>
>
>
>     Thanks,
>     Gang Li
>
>     DolphinScheduler(Incubator) PPMC
>     Gang Li 李岗
>
>     lgcareer@apache.org
>
>     From: zx liu
>     Date: 2020-09-21 17:09
>     To: dev
>     Subject: [DISCUSS] support multi-queries in single sql transformation
> task #3710
>     hi all,
>
>     The current sql task cannot support multiple queries, but my project is
>     very emergency about this feature. I chang this  feature  in my
> local.but
>     I'm not sure if my change is reasonable, so i need some help or
> suggestions。
>
>     hive and sql use the same code to execute sql,
>
>     executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
>     postStatementSqlBinds, createFuncs);
>
>     But the problem here is that hive JDBC does not support multiple
> queries,
>     mysql mssql supports multiple queries. If both mysql mssql  and hive
>     supports multiple queries , so I consider the compatibility of the two
>     here, and modify it to split the sql statement according to the
>     conventional ";", but execute them one by one.
>
>     // support multiQueries 2020/9/16
>     String[] sqlsplit = mainSqlBinds.getSql().split(";");
>     if (sqlsplit.length == 0) {
>     logger.error("please check sqlscript can splited by ';'");
>     return;
>     }
>     Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
>     for (String sqlscript : sqlsplit) {
>     executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
>     preStatementSqlBinds, postStatementSqlBinds, createFuncs);
>     }
>
>     I don’t know if this change is reasonable, I hope you can give some
>     reasonable suggestions
>
>     https://github.com/apache/incubator-dolphinscheduler/issues/3710
>
>     thk!
>
>     当前的sql组件支持正常的多条语句同时执行,但是我们项目对这个功能比较着急,我在本地做了修改,但是我不确定我改的是否合理。
>
>     希望得到大家的建议或者帮助。
>
>     跟踪代码发现,hive 与mysql 使用了同样的执行语句的入口:
>
>     executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
>     postStatementSqlBinds, createFuncs);
>
>
>     有些数据源可能直接在jdbc 的连接参数加上allowmultiqueries=true就可以,但是hive jdbc是不支持
> 批量sql支持的这个功能,
>
>     我的考虑是在不能确定其它的数据源是否也支持多sql查询的功能,所以使用";"分割sql语句依然保持一条一条的语句执行,这样能
>
>     保证这两种情况兼容,同样能够实现基本的功能,代码的改动量很少。修改成这样:
>
>     // support multiQueries 2020/9/16
>     String[] sqlsplit = mainSqlBinds.getSql().split(";");
>     if (sqlsplit.length == 0) {
>     logger.error("please check sqlscript can splited by ';'");
>     return;
>     }
>     Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
>     for (String sqlscript : sqlsplit) {
>     executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
>     preStatementSqlBinds, postStatementSqlBinds, createFuncs);
>     }
>
>     这样修改是否合理,希望能够给予帮助或者建议。
>
>     谢谢! https://github.com/apache/incubator-dolphinscheduler/issues/3710
>

Re: [DISCUSS] support multi-queries in single sql transformation task #3710

Posted by wu shaoj <ga...@apache.org>.
Yes, don't split with semicolon [";"],
So PLEASE DO NOT SUPPORT MULTI SQLS IN SQL TASK !!!
We can add a new task, which type is SQL-SCRIPT, to suport the multil dml SQLs, and not support multi query sqls is better 


On 2020/9/23, 15:30, "boyi" <zh...@163.com> wrote:

    hi:




    Don't split with semicolon [";"], it's a problem


    For example, SQL contains comments with semicolons [";"]


    In this way, there will be problems when the program is executed
    --------------------------------------
    BoYi ZhangE-mail : zhangboyi_mx@163.com
    On 09/23/2020 15:06,lgcareer2019@outlook.com<lg...@outlook.com> wrote:
    Hi,If execute executeFuncAndSql in a loop,it will close and open connection frequently.
    You can try use the `addBatch` and `executeBatch` method of PrepareStatement,
    But it seems hive jdbc didn't support it.

    BTW,Beacause the sql task can send the result by the email now,So If support multiple queries,How to send the result.
    Whether we only support mulitiple non-query statement and support only one select statement?

    Welcome discuss!Thanks!




    Thanks,
    Gang Li

    DolphinScheduler(Incubator) PPMC
    Gang Li 李岗

    lgcareer@apache.org

    From: zx liu
    Date: 2020-09-21 17:09
    To: dev
    Subject: [DISCUSS] support multi-queries in single sql transformation task #3710
    hi all,

    The current sql task cannot support multiple queries, but my project is
    very emergency about this feature. I chang this  feature  in my local.but
    I'm not sure if my change is reasonable, so i need some help or suggestions。

    hive and sql use the same code to execute sql,

    executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
    postStatementSqlBinds, createFuncs);

    But the problem here is that hive JDBC does not support multiple queries,
    mysql mssql supports multiple queries. If both mysql mssql  and hive
    supports multiple queries , so I consider the compatibility of the two
    here, and modify it to split the sql statement according to the
    conventional ";", but execute them one by one.

    // support multiQueries 2020/9/16
    String[] sqlsplit = mainSqlBinds.getSql().split(";");
    if (sqlsplit.length == 0) {
    logger.error("please check sqlscript can splited by ';'");
    return;
    }
    Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
    for (String sqlscript : sqlsplit) {
    executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
    preStatementSqlBinds, postStatementSqlBinds, createFuncs);
    }

    I don’t know if this change is reasonable, I hope you can give some
    reasonable suggestions

    https://github.com/apache/incubator-dolphinscheduler/issues/3710

    thk!

    当前的sql组件支持正常的多条语句同时执行,但是我们项目对这个功能比较着急,我在本地做了修改,但是我不确定我改的是否合理。

    希望得到大家的建议或者帮助。

    跟踪代码发现,hive 与mysql 使用了同样的执行语句的入口:

    executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
    postStatementSqlBinds, createFuncs);


    有些数据源可能直接在jdbc 的连接参数加上allowmultiqueries=true就可以,但是hive jdbc是不支持 批量sql支持的这个功能,

    我的考虑是在不能确定其它的数据源是否也支持多sql查询的功能,所以使用";"分割sql语句依然保持一条一条的语句执行,这样能

    保证这两种情况兼容,同样能够实现基本的功能,代码的改动量很少。修改成这样:

    // support multiQueries 2020/9/16
    String[] sqlsplit = mainSqlBinds.getSql().split(";");
    if (sqlsplit.length == 0) {
    logger.error("please check sqlscript can splited by ';'");
    return;
    }
    Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
    for (String sqlscript : sqlsplit) {
    executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
    preStatementSqlBinds, postStatementSqlBinds, createFuncs);
    }

    这样修改是否合理,希望能够给予帮助或者建议。

    谢谢! https://github.com/apache/incubator-dolphinscheduler/issues/3710

Re: [DISCUSS] support multi-queries in single sql transformation task #3710

Posted by boyi <zh...@163.com>.
hi:




Don't split with semicolon [";"], it's a problem


For example, SQL contains comments with semicolons [";"]


In this way, there will be problems when the program is executed
--------------------------------------
BoYi ZhangE-mail : zhangboyi_mx@163.com
On 09/23/2020 15:06,lgcareer2019@outlook.com<lg...@outlook.com> wrote:
Hi,If execute executeFuncAndSql in a loop,it will close and open connection frequently.
You can try use the `addBatch` and `executeBatch` method of PrepareStatement,
But it seems hive jdbc didn't support it.

BTW,Beacause the sql task can send the result by the email now,So If support multiple queries,How to send the result.
Whether we only support mulitiple non-query statement and support only one select statement?

Welcome discuss!Thanks!




Thanks,
Gang Li

DolphinScheduler(Incubator) PPMC
Gang Li 李岗

lgcareer@apache.org

From: zx liu
Date: 2020-09-21 17:09
To: dev
Subject: [DISCUSS] support multi-queries in single sql transformation task #3710
hi all,

The current sql task cannot support multiple queries, but my project is
very emergency about this feature. I chang this  feature  in my local.but
I'm not sure if my change is reasonable, so i need some help or suggestions。

hive and sql use the same code to execute sql,

executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
postStatementSqlBinds, createFuncs);

But the problem here is that hive JDBC does not support multiple queries,
mysql mssql supports multiple queries. If both mysql mssql  and hive
supports multiple queries , so I consider the compatibility of the two
here, and modify it to split the sql statement according to the
conventional ";", but execute them one by one.

// support multiQueries 2020/9/16
String[] sqlsplit = mainSqlBinds.getSql().split(";");
if (sqlsplit.length == 0) {
logger.error("please check sqlscript can splited by ';'");
return;
}
Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
for (String sqlscript : sqlsplit) {
executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
preStatementSqlBinds, postStatementSqlBinds, createFuncs);
}

I don’t know if this change is reasonable, I hope you can give some
reasonable suggestions

https://github.com/apache/incubator-dolphinscheduler/issues/3710

thk!

当前的sql组件支持正常的多条语句同时执行,但是我们项目对这个功能比较着急,我在本地做了修改,但是我不确定我改的是否合理。

希望得到大家的建议或者帮助。

跟踪代码发现,hive 与mysql 使用了同样的执行语句的入口:

executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
postStatementSqlBinds, createFuncs);


有些数据源可能直接在jdbc 的连接参数加上allowmultiqueries=true就可以,但是hive jdbc是不支持 批量sql支持的这个功能,

我的考虑是在不能确定其它的数据源是否也支持多sql查询的功能,所以使用";"分割sql语句依然保持一条一条的语句执行,这样能

保证这两种情况兼容,同样能够实现基本的功能,代码的改动量很少。修改成这样:

// support multiQueries 2020/9/16
String[] sqlsplit = mainSqlBinds.getSql().split(";");
if (sqlsplit.length == 0) {
logger.error("please check sqlscript can splited by ';'");
return;
}
Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
for (String sqlscript : sqlsplit) {
executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
preStatementSqlBinds, postStatementSqlBinds, createFuncs);
}

这样修改是否合理,希望能够给予帮助或者建议。

谢谢! https://github.com/apache/incubator-dolphinscheduler/issues/3710

Re: [DISCUSS] support multi-queries in single sql transformation task #3710

Posted by "lgcareer2019@outlook.com" <lg...@outlook.com>.
Hi,If execute executeFuncAndSql in a loop,it will close and open connection frequently.
You can try use the `addBatch` and `executeBatch` method of PrepareStatement,
But it seems hive jdbc didn't support it.

BTW,Beacause the sql task can send the result by the email now,So If support multiple queries,How to send the result.
Whether we only support mulitiple non-query statement and support only one select statement?

Welcome discuss!Thanks!




Thanks,
Gang Li

DolphinScheduler(Incubator) PPMC
Gang Li 李岗

lgcareer@apache.org
 
From: zx liu
Date: 2020-09-21 17:09
To: dev
Subject: [DISCUSS] support multi-queries in single sql transformation task #3710
hi all,
 
The current sql task cannot support multiple queries, but my project is
very emergency about this feature. I chang this  feature  in my local.but
I'm not sure if my change is reasonable, so i need some help or suggestions。
 
hive and sql use the same code to execute sql,
 
executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
postStatementSqlBinds, createFuncs);
 
But the problem here is that hive JDBC does not support multiple queries,
mysql mssql supports multiple queries. If both mysql mssql  and hive
supports multiple queries , so I consider the compatibility of the two
here, and modify it to split the sql statement according to the
conventional ";", but execute them one by one.
 
// support multiQueries 2020/9/16
String[] sqlsplit = mainSqlBinds.getSql().split(";");
if (sqlsplit.length == 0) {
    logger.error("please check sqlscript can splited by ';'");
    return;
}
Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
for (String sqlscript : sqlsplit) {
    executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
preStatementSqlBinds, postStatementSqlBinds, createFuncs);
}
 
I don’t know if this change is reasonable, I hope you can give some
reasonable suggestions
 
https://github.com/apache/incubator-dolphinscheduler/issues/3710
 
thk!
 
当前的sql组件支持正常的多条语句同时执行,但是我们项目对这个功能比较着急,我在本地做了修改,但是我不确定我改的是否合理。
 
希望得到大家的建议或者帮助。
 
跟踪代码发现,hive 与mysql 使用了同样的执行语句的入口:
 
executeFuncAndSql(mainSqlBinds, preStatementSqlBinds,
postStatementSqlBinds, createFuncs);
 
 
有些数据源可能直接在jdbc 的连接参数加上allowmultiqueries=true就可以,但是hive jdbc是不支持 批量sql支持的这个功能,
 
我的考虑是在不能确定其它的数据源是否也支持多sql查询的功能,所以使用";"分割sql语句依然保持一条一条的语句执行,这样能
 
保证这两种情况兼容,同样能够实现基本的功能,代码的改动量很少。修改成这样:
 
// support multiQueries 2020/9/16
String[] sqlsplit = mainSqlBinds.getSql().split(";");
if (sqlsplit.length == 0) {
    logger.error("please check sqlscript can splited by ';'");
    return;
}
Map<Integer, Property> sqlParamsMap = mainSqlBinds.getParamsMap();
for (String sqlscript : sqlsplit) {
    executeFuncAndSql(new SqlBinds(sqlscript, sqlParamsMap),
preStatementSqlBinds, postStatementSqlBinds, createFuncs);
}
 
这样修改是否合理,希望能够给予帮助或者建议。
 
谢谢! https://github.com/apache/incubator-dolphinscheduler/issues/3710