This is an automated email from the ASF dual-hosted git repository. zhongjiajie pushed a commit to branch 3.0.1-prepare in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
commit 59e745be0a485855f9fdf60275670b8d1a14a463 Author: 陈家名 <[email protected]> AuthorDate: Sat Aug 27 12:17:06 2022 +0800 [fix][python] Sql pattern add truncate. (#11666) (cherry picked from commit 564a815d218f06a6b55dd9da790bdbf87bd36a50) --- .../pydolphinscheduler/src/pydolphinscheduler/tasks/sql.py | 2 +- dolphinscheduler-python/pydolphinscheduler/tests/tasks/test_sql.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sql.py b/dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sql.py index a1259824f1..716a024daf 100644 --- a/dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sql.py +++ b/dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sql.py @@ -98,7 +98,7 @@ class Sql(Task): return self.param_sql_type pattern_select_str = ( "^(?!(.* |)insert |(.* |)delete |(.* |)drop " - "|(.* |)update |(.* |)alter |(.* |)create ).*" + "|(.* |)update |(.* |)truncate |(.* |)alter |(.* |)create ).*" ) pattern_select = re.compile(pattern_select_str, re.IGNORECASE) if pattern_select.match(self.sql) is None: diff --git a/dolphinscheduler-python/pydolphinscheduler/tests/tasks/test_sql.py b/dolphinscheduler-python/pydolphinscheduler/tests/tasks/test_sql.py index ee0acc442e..50ccd946a9 100644 --- a/dolphinscheduler-python/pydolphinscheduler/tests/tasks/test_sql.py +++ b/dolphinscheduler-python/pydolphinscheduler/tests/tasks/test_sql.py @@ -54,6 +54,7 @@ from pydolphinscheduler.tasks.sql import Sql, SqlType ("delete from table_name where id < 10", None, SqlType.NOT_SELECT), ("alter table table_name add column col1 int", None, SqlType.NOT_SELECT), ("create table table_name2 (col1 int)", None, SqlType.NOT_SELECT), + ("truncate table table_name", None, SqlType.NOT_SELECT), ("create table table_name2 (col1 int)", SqlType.SELECT, SqlType.SELECT), ("select 1", SqlType.NOT_SELECT, SqlType.NOT_SELECT), ("create table table_name2 (col1 int)", SqlType.NOT_SELECT, SqlType.NOT_SELECT),
