From c6358045f9d61af63c96833cb6682d6f382a6408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Monta=C3=B1ola?= <35972814+gmontanola@users.noreply.github.com> Date: Sat, 22 Aug 2020 16:19:37 -0300 Subject: [PATCH] Fixes S3ToRedshift COPY query (#10436) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 🐛 Wrong S3 URI on COPY query The S3 URI on COPY query was appending the target Redshift table to the S3 object key. * test: 💍 Fixed typo on test query The COPY query that the operator used is the same query the test uses. --- airflow/providers/amazon/aws/transfers/s3_to_redshift.py | 2 +- tests/providers/amazon/aws/transfers/test_s3_to_redshift.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/airflow/providers/amazon/aws/transfers/s3_to_redshift.py b/airflow/providers/amazon/aws/transfers/s3_to_redshift.py index fd14da29916aa..1ddbeaeef5681 100644 --- a/airflow/providers/amazon/aws/transfers/s3_to_redshift.py +++ b/airflow/providers/amazon/aws/transfers/s3_to_redshift.py @@ -96,7 +96,7 @@ def execute(self, context): copy_query = """ COPY {schema}.{table} - FROM 's3://{s3_bucket}/{s3_key}/{table}' + FROM 's3://{s3_bucket}/{s3_key}' with credentials 'aws_access_key_id={access_key};aws_secret_access_key={secret_key}' {copy_options}; diff --git a/tests/providers/amazon/aws/transfers/test_s3_to_redshift.py b/tests/providers/amazon/aws/transfers/test_s3_to_redshift.py index 32da61d955ef5..0c619db8d6097 100644 --- a/tests/providers/amazon/aws/transfers/test_s3_to_redshift.py +++ b/tests/providers/amazon/aws/transfers/test_s3_to_redshift.py @@ -55,7 +55,7 @@ def test_execute(self, mock_run, mock_session): copy_query = """ COPY {schema}.{table} - FROM 's3://{s3_bucket}/{s3_key}/{table}' + FROM 's3://{s3_bucket}/{s3_key}' with credentials 'aws_access_key_id={access_key};aws_secret_access_key={secret_key}' {copy_options};