jsjasonseba commented on code in PR #50178: URL: https://github.com/apache/airflow/pull/50178#discussion_r2102786740
########## providers/alibaba/src/airflow/providers/alibaba/cloud/operators/maxcompute.py: ########## @@ -0,0 +1,146 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""This module contains Alibaba Cloud MaxCompute operators.""" + +from __future__ import annotations + +from collections.abc import Sequence +from typing import TYPE_CHECKING + +from airflow.models import BaseOperator +from airflow.providers.alibaba.cloud.hooks.maxcompute import MaxComputeHook +from airflow.providers.alibaba.cloud.links.maxcompute import MaxComputeLogViewLink + +if TYPE_CHECKING: + from odps.models import Instance + + from airflow.utils.context import Context + + +class MaxComputeSQLOperator(BaseOperator): + """ + Executes an SQL statement in MaxCompute. + + Waits for the SQL task instance to complete and returns instance id. + + :param sql: The SQL statement to run. + :param project: The project ID to use. + :param endpoint: The endpoint to use. + :param priority: The priority of the SQL statement ranges from 0 to 9, + applicable to projects with the job priority feature enabled. + Takes precedence over the `odps.instance.priority` setting from `hints`. + Defaults to 9. + See https://www.alibabacloud.com/help/en/maxcompute/user-guide/job-priority + for details. + :param running_cluster: The cluster to run the SQL statement on. + :param hints: Hints for setting runtime parameters. See + https://pyodps.readthedocs.io/en/latest/base-sql.html#id4 and + https://www.alibabacloud.com/help/en/maxcompute/user-guide/flag-parameters + for details. + :param aliases: Aliases for the SQL statement. + :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 cancel_on_kill: Flag which indicates whether to stop running instance + or not when task is killed. Default is True. + """ + + template_fields: Sequence[str] = ( + "sql", + "project", + "endpoint", + "priority", + "running_cluster", + "hints", + "aliases", + "default_schema", + "quota_name", + "alibabacloud_conn_id", + ) + template_ext: Sequence[str] = (".sql",) + template_fields_renderers = {"sql": "sql"} + operator_extra_links = (MaxComputeLogViewLink(),) + + def __init__( + self, + *, + sql: str, + project: str | None = None, Review Comment: `project` is based on the parameter from the `pyodps` [client](https://pyodps.readthedocs.io/en/latest/#quick-start). I do agree though that `project_id` is a better name -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org