Browse Source

[fix][python] Correct variable type of SQL type (#10464)

3.1.0-release
陈家名 2 years ago committed by GitHub
parent
commit
f512e3c31f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sql.py
  2. 4
      dolphinscheduler-python/pydolphinscheduler/tests/tasks/test_sql.py

8
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sql.py

@ -31,8 +31,8 @@ log = logging.getLogger(__file__)
class SqlType:
"""SQL type, for now it just contain `SELECT` and `NO_SELECT`."""
SELECT = 0
NOT_SELECT = 1
SELECT = "0"
NOT_SELECT = "1"
class Sql(Task):
@ -64,7 +64,7 @@ class Sql(Task):
name: str,
datasource_name: str,
sql: str,
sql_type: Optional[int] = None,
sql_type: Optional[str] = None,
pre_statements: Optional[str] = None,
post_statements: Optional[str] = None,
display_rows: Optional[int] = 10,
@ -80,7 +80,7 @@ class Sql(Task):
self.display_rows = display_rows
@property
def sql_type(self) -> int:
def sql_type(self) -> str:
"""Judgement sql type, it will return the SQL type for type `SELECT` or `NOT_SELECT`.
If `param_sql_type` dot not specific, will use regexp to check

4
dolphinscheduler-python/pydolphinscheduler/tests/tasks/test_sql.py

@ -89,7 +89,7 @@ def test_get_sql_type(
"sql": "select 1",
"type": "MYSQL",
"datasource": 1,
"sqlType": SqlType.SELECT,
"sqlType": "0",
"preStatements": [],
"postStatements": [],
"displayRows": 10,
@ -138,7 +138,7 @@ def test_sql_get_define(mock_datasource):
"type": "MYSQL",
"datasource": 1,
"sql": command,
"sqlType": SqlType.SELECT,
"sqlType": "0",
"displayRows": 10,
"preStatements": [],
"postStatements": [],

Loading…
Cancel
Save