josh-fell commented on code in PR #36171:
URL: https://github.com/apache/airflow/pull/36171#discussion_r1424797740


##########
airflow/providers/amazon/aws/hooks/athena_sql.py:
##########
@@ -0,0 +1,107 @@
+# 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 functools import cached_property
+from typing import TYPE_CHECKING
+
+import pyathena
+from sqlalchemy import create_engine
+
+from airflow.exceptions import AirflowException
+from airflow.providers.common.sql.hooks.sql import DbApiHook
+
+if TYPE_CHECKING:
+    from pyathena.connection import Connection as AthenaConnection
+
+
+class AthenaSQLHook(DbApiHook):
+    """Execute statements against Amazon Athena.
+
+    .. note::
+    get_sqlalchemy_engine() and get_uri() depends on SQLAlchemy and PyAthena.

Review Comment:
   ```suggestion
       .. note::
           get_sqlalchemy_engine() and get_uri() depends on SQLAlchemy and 
PyAthena.
   ```
   This _should_ allow the note to render correctly in the API docs in Airflow 
for this hook.



##########
airflow/providers/amazon/aws/hooks/athena_sql.py:
##########
@@ -0,0 +1,107 @@
+# 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 functools import cached_property
+from typing import TYPE_CHECKING
+
+import pyathena
+from sqlalchemy import create_engine
+
+from airflow.exceptions import AirflowException
+from airflow.providers.common.sql.hooks.sql import DbApiHook
+
+if TYPE_CHECKING:
+    from pyathena.connection import Connection as AthenaConnection
+
+
+class AthenaSQLHook(DbApiHook):
+    """Execute statements against Amazon Athena.
+
+    .. note::
+    get_sqlalchemy_engine() and get_uri() depends on SQLAlchemy and PyAthena.
+    """
+
+    conn_name_attr = "athena_conn_id"
+    default_conn_name = "athena_default"
+    conn_type = "athena"
+    hook_name = "Amazon Athena"
+    supports_autocommit = True
+
+    def __init__(self, *args, athena_conn_id: str = "athena_default", 
**kwargs) -> None:

Review Comment:
   Would you mind adding `athena_conn_id` to the docstring please?



##########
airflow/providers/amazon/aws/hooks/athena_sql.py:
##########
@@ -0,0 +1,107 @@
+# 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 functools import cached_property
+from typing import TYPE_CHECKING
+
+import pyathena
+from sqlalchemy import create_engine
+
+from airflow.exceptions import AirflowException
+from airflow.providers.common.sql.hooks.sql import DbApiHook
+
+if TYPE_CHECKING:
+    from pyathena.connection import Connection as AthenaConnection
+
+
+class AthenaSQLHook(DbApiHook):
+    """Execute statements against Amazon Athena.
+
+    .. note::
+    get_sqlalchemy_engine() and get_uri() depends on SQLAlchemy and PyAthena.
+    """
+
+    conn_name_attr = "athena_conn_id"
+    default_conn_name = "athena_default"
+    conn_type = "athena"
+    hook_name = "Amazon Athena"
+    supports_autocommit = True
+
+    def __init__(self, *args, athena_conn_id: str = "athena_default", 
**kwargs) -> None:
+        super().__init__(*args, **kwargs)
+        self.athena_conn_id = athena_conn_id
+
+    @cached_property
+    def conn(self):
+        return self.get_connection(self.athena_conn_id)  # type: 
ignore[attr-defined]
+
+    def _get_conn_params(self) -> dict[str, str | int | None]:
+        """Retrieve connection parameters."""
+        conn = self.conn
+
+        s3_staging_dir = conn.extra_dejson.get("s3_staging_dir", None)
+        if not s3_staging_dir:

Review Comment:
   ```suggestion
           if not (s3_staging_dir := conn.extra_dejson.get("s3_staging_dir", 
None)):
   ```
   Since the minimum-supported Python version for Airflow now is 3.8, you could 
use the [walrus 
operator](https://docs.python.org/3/whatsnew/3.8.html#assignment-expressions) 
if you like. Not a strong opinion; just pointing it out.



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