You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/02/26 15:09:20 UTC

[GitHub] [airflow] dstandish commented on a change in pull request #14415: SnowflakeToS3Operator

dstandish commented on a change in pull request #14415:
URL: https://github.com/apache/airflow/pull/14415#discussion_r583704890



##########
File path: airflow/providers/amazon/aws/transfers/snowflake_to_s3.py
##########
@@ -0,0 +1,150 @@
+#
+# 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.
+"""Transfers data from Snowflake into a S3 Bucket."""
+from typing import List, Optional
+
+from airflow.models import BaseOperator
+from airflow.providers.snowflake.hooks.snowflake import SnowflakeHook
+from airflow.utils.decorators import apply_defaults
+
+
+class SnowflakeToS3Operator(BaseOperator):

Review comment:
       Since you are using unload for this, I recomment making it storage agnostic. 
   
   It's the same case as that other discussion we had going s3-to-snowflake.
   
   The snowflake unload command doesn't care what storage is behind the stage.
   
   So I recommend making this a generic SnowflakeUnloadOperator.  There's no need to use s3-specific terminology.  

##########
File path: airflow/providers/amazon/aws/transfers/snowflake_to_s3.py
##########
@@ -0,0 +1,150 @@
+#
+# 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.
+"""Transfers data from Snowflake into a S3 Bucket."""
+from typing import List, Optional
+
+from airflow.models import BaseOperator
+from airflow.providers.snowflake.hooks.snowflake import SnowflakeHook
+from airflow.utils.decorators import apply_defaults
+
+
+class SnowflakeToS3Operator(BaseOperator):
+    """
+    UNLOAD a query or a table from Snowflake to S3. It is not necessary a conn to S3 because
+    Snowflake handles it. You have to follow one of the setups in:
+    https://docs.snowflake.com/en/user-guide/data-load-s3-config.html
+
+    :param stage: Reference to a specific Snowflake stage to copy the data into it. This allows you to use
+        the method 'Configuring AWS IAM User Credentials' for unloading data to s3. If this is passed,
+        s3_bucket can't be used and file_format is not necessary
+    :type stage: str
+    :param warehouse: reference to a specific snowflake warehouse to override the one in the conn
+    :type warehouse: str
+    :param database: reference to a specific snowflake database to override the one in the conn
+    :type warehouse: str
+    :param s3_bucket: reference to a specific S3 bucket where the data will be saved. For using it, you
+        should have done the one-time setup 'Configuring a Snowflake Storage Integration'
+    :type s3_bucket: str
+    :param s3_key: reference to a specific S3 key within a bucket or stage.
+    :type s3_key: str
+    :param file_format: can be either a previous file format created in Snowflake

Review comment:
       it's not necessarily a key.  If the data is large snowflake will split files.  Perhaps better to call it `path` or `prefix`?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org