Taragolis commented on code in PR #37458:
URL: https://github.com/apache/airflow/pull/37458#discussion_r1522956524


##########
airflow/providers/yandex/operators/yandexcloud_yq.py:
##########
@@ -0,0 +1,89 @@
+# 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.
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any, Sequence
+
+from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
+from airflow.providers.yandex.hooks.yq import YQHook
+from airflow.providers.yandex.links.yq import YQLink
+
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
+
+
+class YQExecuteQueryOperator(SQLExecuteQueryOperator):

Review Comment:
   Is it required to extend `SQLExecuteQueryOperator`? asked because this 
generic class for iterate around Hooks which implements (or thought that it 
implements) DBApi2.
   
   If not just better to use BaseOperator instead



##########
airflow/providers/yandex/provider.yaml:
##########


Review Comment:
   need also add selected packages as dependencies, this one also a core 
dependency, however it can't be guarantied that it would be in the future
   
   ```yaml
   - python-dateutil>=2.3
   # Requests 3 if it will be released, will be heavily breaking.
   - requests>=2.27.0,<3
   ```
   
   `python-dateutil` to be honest could be >=2.8.0, which released 3 years ago



##########
airflow/providers/yandex/operators/yandexcloud_yq.py:
##########
@@ -0,0 +1,89 @@
+# 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.
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any, Sequence
+
+from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
+from airflow.providers.yandex.hooks.yq import YQHook
+from airflow.providers.yandex.links.yq import YQLink
+
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
+
+
+class YQExecuteQueryOperator(SQLExecuteQueryOperator):
+    """
+    Executes sql code using Yandex Query service.
+
+    :param sql: the SQL code to be executed as a single string
+    :param name: name of the query in YandexQuery
+    :param folder_id: cloud folder id where to create query
+    :param connection_id: Airflow connection ID to get parameters from
+    :param folder_id: cloud folder id where to create query
+    """
+
+    operator_extra_links = (YQLink(),)
+    template_fields: Sequence[str] = ("sql",)
+    template_fields_renderers = {"sql": "sql"}
+    template_ext: Sequence[str] = (".sql",)
+    ui_color = "#ededed"
+
+    def __init__(
+        self,
+        *,
+        name: str | None = None,
+        folder_id: str | None = None,
+        connection_id: str | None = None,
+        public_ssh_key: str | None = None,
+        service_account_id: str | None = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        self.name = name
+        self.folder_id = folder_id
+        self.connection_id = connection_id
+        self.public_ssh_key = public_ssh_key
+        self.service_account_id = service_account_id
+
+        self.hook: YQHook | None = None

Review Comment:
   Could be a cached property, e.g
   
   ```python
   @cached_property
   def hook() -> YQHook:
       return YQHook(
               yandex_conn_id=self.connection_id,
               default_folder_id=self.folder_id,
               default_public_ssh_key=self.public_ssh_key,
               default_service_account_id=self.service_account_id,
           )
   ```
   
   It would be evaluated first time when it accessed



##########
tests/providers/yandex/operators/test_yandexcloud_yq.py:
##########


Review Comment:
   `tests/providers/yandex/operators/test_yandexcloud_yq.py` -> 
`tests/providers/yandex/operators/test_yq.py`



##########
airflow/providers/yandex/operators/yandexcloud_yq.py:
##########
@@ -0,0 +1,89 @@
+# 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.
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any, Sequence
+
+from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
+from airflow.providers.yandex.hooks.yq import YQHook
+from airflow.providers.yandex.links.yq import YQLink
+
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
+
+
+class YQExecuteQueryOperator(SQLExecuteQueryOperator):
+    """
+    Executes sql code using Yandex Query service.
+
+    :param sql: the SQL code to be executed as a single string
+    :param name: name of the query in YandexQuery
+    :param folder_id: cloud folder id where to create query
+    :param connection_id: Airflow connection ID to get parameters from
+    :param folder_id: cloud folder id where to create query
+    """
+
+    operator_extra_links = (YQLink(),)
+    template_fields: Sequence[str] = ("sql",)
+    template_fields_renderers = {"sql": "sql"}
+    template_ext: Sequence[str] = (".sql",)
+    ui_color = "#ededed"
+
+    def __init__(
+        self,
+        *,
+        name: str | None = None,
+        folder_id: str | None = None,
+        connection_id: str | None = None,

Review Comment:
   ```suggestion
           yandex_conn_id: str | None = None,
   ```
   
   I guess better to use same naming elsewhere, do not forget to change in 
docstring and into the other places



##########
airflow/providers/yandex/operators/yandexcloud_yq.py:
##########


Review Comment:
   `airflow/providers/yandex/operators/yandexcloud_yq.py` -> 
`airflow/providers/yandex/operators/yq.py` the same naming as for Hook



-- 
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

Reply via email to