vincbeck commented on code in PR #65816: URL: https://github.com/apache/airflow/pull/65816#discussion_r3139832269
########## providers/amazon/tests/system/amazon/aws/example_s3tables.py: ########## @@ -0,0 +1,147 @@ +# 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 datetime import datetime + +from airflow.decorators import task +from airflow.providers.amazon.aws.operators.s3tables import S3TablesCreateTableOperator +from airflow.providers.common.compat.sdk import DAG, chain + +try: + from airflow.sdk import TriggerRule +except ImportError: + from airflow.utils.trigger_rule import TriggerRule + +from system.amazon.aws.utils import ENV_ID_KEY, SystemTestContextBuilder + +DAG_ID = "example_s3tables" + +sys_test_context_task = SystemTestContextBuilder().build() + +SCHEMA = { + "iceberg": { + "schema": { + "fields": [ + {"name": "id", "type": "int", "required": True}, + {"name": "name", "type": "string", "required": False}, + ] + } + } +} + +with DAG( + dag_id=DAG_ID, + schedule="@once", + start_date=datetime(2021, 1, 1), + catchup=False, + tags=["example"], Review Comment: We removed tag from AWS system tests in the last few months, they do not add real value ```suggestion ``` ########## providers/amazon/tests/system/amazon/aws/example_s3tables.py: ########## @@ -0,0 +1,147 @@ +# 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 datetime import datetime + +from airflow.decorators import task +from airflow.providers.amazon.aws.operators.s3tables import S3TablesCreateTableOperator +from airflow.providers.common.compat.sdk import DAG, chain + +try: + from airflow.sdk import TriggerRule +except ImportError: + from airflow.utils.trigger_rule import TriggerRule + +from system.amazon.aws.utils import ENV_ID_KEY, SystemTestContextBuilder + +DAG_ID = "example_s3tables" + +sys_test_context_task = SystemTestContextBuilder().build() + +SCHEMA = { + "iceberg": { + "schema": { + "fields": [ + {"name": "id", "type": "int", "required": True}, + {"name": "name", "type": "string", "required": False}, + ] + } + } +} + +with DAG( + dag_id=DAG_ID, + schedule="@once", + start_date=datetime(2021, 1, 1), + catchup=False, + tags=["example"], +) as dag: + test_context = sys_test_context_task() + env_id = test_context[ENV_ID_KEY] + + bucket_name = f"{env_id}-s3tables" + namespace = f"{env_id}ns" + table_name = f"{env_id}tbl" Review Comment: nit ```suggestion namespace = f"{env_id}-ns" table_name = f"{env_id}-tbl" ``` ########## providers/amazon/src/airflow/providers/amazon/aws/hooks/s3tables.py: ########## @@ -0,0 +1,73 @@ +# +# 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. +"""Interact with Amazon S3 Tables.""" + +from __future__ import annotations + +from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook + + +class S3TablesHook(AwsBaseHook): Review Comment: We also recommend to not create hooks which are only thin wrapper on top of boto3. Basically if a hook method is only calling boto3 method without real added value, then we do not recommend creating it. You can call the boto3 API directly in the operator -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
