[dolphinscheduler-task-api] 数据库名前缀通过参数传入前缀多了单引号 #14345
Unanswered
zsl461975543
asked this question in
Q&A
Replies: 3 comments
-
这个东西,可以修改代码,加个配置参数,来判断是否要加双引号吧。或者学mysql plus 用# 和$区分,你觉得怎么样?cc @ruanwenjun @davidzollo |
Beta Was this translation helpful? Give feedback.
0 replies
-
你需要扩展一下 SQL 任务类型,将 You need to extend the SQL task type, pass the |
Beta Was this translation helpful? Give feedback.
0 replies
-
我也遇到类似的问题,3.2.2,平台依然没有;请问楼主是怎么解决的? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
dolphinscheduler 版本为:3.1.6
对应的jar #包:dolphinscheduler-task-api-3.1.6.jar
*********** background ******************
尼日利亚:ALTER TABLE ng_nrt.p_player DELETE WHERE toDate(register_date) >= '2023-06-03' and toDate(register_date) <= '2023-06-04'
肯尼利亚:ALTER TABLE ke_nrt.p_player DELETE WHERE toDate(register_date) >= '2023-06-03' and toDate(register_date) <= '2023-06-04'
但实际得到的是:(数据库前缀多了单引号),导致执行出错
尼日利亚:ALTER TABLE 'ng_'nrt.p_player DELETE WHERE toDate(register_date) >= '2023-06-03' and toDate(register_date) <= '2023-06-04'
肯尼利亚:ALTER TABLE 'ke_'nrt.p_player DELETE WHERE toDate(register_date) >= '2023-06-03' and toDate(register_date) <= '2023-06-04'
类 org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils
方法:setInParameter 解析DataType.VARCHAR 的时候,按照字符串进行处理(Property 类的value 为String)
类 org.apache.dolphinscheduler.plugin.task.sql.SqlTask
方法:prepareStatementAndBind
ParameterUtils.setInParameter(entry.getKey(), stmt, prop.getType(), prop.getValue())
不知道该如何应对这样的场景?
************************ERROR log info **********************
[INFO] 2023-06-13 11:32:11.002 +0000 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.sql.SqlTask:[123] - [WorkflowInstance-21][TaskInstance-29] - Full sql parameters: SqlParameters{type='CLICKHOUSE', datasource=2, sql='ALTER TABLE ${country}nrt.p_player DELETE WHERE toDate(register_date) >= ${begin_date} and toDate(register_date) <= ${end_date}', sqlType=1, sendEmail=null, displayRows=10, limit=0, segmentSeparator=, udfs='null', showType='null', connParams='null', groupId='0', title='null', preStatements=[], postStatements=[]}
[INFO] 2023-06-13 11:32:11.002 +0000 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.sql.SqlTask:[124] - [WorkflowInstance-21][TaskInstance-29] - sql type : CLICKHOUSE, datasource : 2, sql : ALTER TABLE ${country}nrt.p_player DELETE WHERE toDate(register_date) >= ${begin_date} and toDate(register_date) <= ${end_date} , localParams : [],udfs : null,showType : null,connParams : null,varPool : [] ,query max result limit 0
[INFO] 2023-06-13 11:32:11.013 +0000 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.sql.SqlTask:[374] - [WorkflowInstance-21][TaskInstance-29] - prepare statement replace sql : ALTER TABLE ?nrt.p_player DELETE WHERE toDate(register_date) >= ? and toDate(register_date) <= ?, sql parameters : {1=Property{prop='country', direct=IN, type=VARCHAR, value='ng_'}, 2=Property{prop='begin_date', direct=IN, type=VARCHAR, value='2023-06-01'}, 3=Property{prop='end_date', direct=IN, type=VARCHAR, value='2023-06-10'}}
[ERROR] 2023-06-13 11:10:31.026 +0000 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.sql.SqlTask:[219] - [WorkflowInstance-18][TaskInstance-24] - execute sql error: Code: 62. DB::Exception: Syntax error: failed at position 13 (''ng_''): 'ng_'nrt.p_player DELETE WHERE toDate(register_date) >= '2023-06-01' and toDate(register_date) <= '2023-06-10'. Expected identifier. (SYNTAX_ERROR) (version 22.7.1.1032 (official build))
Beta Was this translation helpful? Give feedback.
All reactions