Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def fallback_to_default_project_endpoint(func: Callable[..., RT]) -> Callable[..
def inner_wrapper(self, **kwargs) -> RT:
required_args = ("project", "endpoint")
for arg_name in required_args:
kwargs[arg_name] = kwargs.get(arg_name, getattr(self, arg_name))
# Use the value from kwargs if it is provided and value is not None, otherwise use the
# value from the connection extra property.
kwargs[arg_name] = getattr(self, arg_name) if kwargs.get(arg_name) is None else kwargs[arg_name]
if not kwargs[arg_name]:
raise MaxComputeConfigurationException(
f'"{arg_name}" must be passed either as '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class MaxComputeSQLOperator(BaseOperator):
:param default_schema: The default schema to use.
:param quota_name: The quota name to use.
Defaults to project default quota if not specified.
:param alibabacloud_conn_id: The connection ID to use. Defaults to
`alibabacloud_default` if not specified.
:param maxcompute_conn_id: The connection ID to use. Defaults to
`maxcompute_default` if not specified.
:param cancel_on_kill: Flag which indicates whether to stop running instance
or not when task is killed. Default is True.
"""
Expand All @@ -72,7 +72,7 @@ class MaxComputeSQLOperator(BaseOperator):
"aliases",
"default_schema",
"quota_name",
"alibabacloud_conn_id",
"maxcompute_conn_id",
)
template_ext: Sequence[str] = (".sql",)
template_fields_renderers = {"sql": "sql"}
Expand All @@ -90,7 +90,7 @@ def __init__(
aliases: dict[str, str] | None = None,
default_schema: str | None = None,
quota_name: str | None = None,
alibabacloud_conn_id: str = "alibabacloud_default",
maxcompute_conn_id: str = "maxcompute_default",
cancel_on_kill: bool = True,
**kwargs,
) -> None:
Expand All @@ -104,13 +104,13 @@ def __init__(
self.aliases = aliases
self.default_schema = default_schema
self.quota_name = quota_name
self.alibabacloud_conn_id = alibabacloud_conn_id
self.maxcompute_conn_id = maxcompute_conn_id
self.cancel_on_kill = cancel_on_kill
self.hook: MaxComputeHook | None = None
self.instance: Instance | None = None

def execute(self, context: Context) -> str:
self.hook = MaxComputeHook(alibabacloud_conn_id=self.alibabacloud_conn_id)
self.hook = MaxComputeHook(maxcompute_conn_id=self.maxcompute_conn_id)

self.instance = self.hook.run_sql(
sql=self.sql,
Expand Down