This is an automated email from the ASF dual-hosted git repository.
zhongjiajie pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 564a815d21 [fix][python] Sql pattern add truncate. (#11666)
564a815d21 is described below
commit 564a815d218f06a6b55dd9da790bdbf87bd36a50
Author: 陈家名 <[email protected]>
AuthorDate: Sat Aug 27 12:17:06 2022 +0800
[fix][python] Sql pattern add truncate. (#11666)
---
.../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),