[AIRFLOW-1119] Fix unload query so headers are on first row[]

Closes #2245 from th11/airflow-1119-fix


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/07ebc46e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/07ebc46e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/07ebc46e

Branch: refs/heads/v1-8-test
Commit: 07ebc46ea7237f554477f83575ec65df95b321f0
Parents: 34f072a
Author: Thomas Hofer <[email protected]>
Authored: Tue Apr 25 11:31:31 2017 +0200
Committer: Maxime Beauchemin <[email protected]>
Committed: Thu Jun 8 08:36:20 2017 -0700

----------------------------------------------------------------------
 airflow/operators/redshift_to_s3_operator.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/07ebc46e/airflow/operators/redshift_to_s3_operator.py
----------------------------------------------------------------------
diff --git a/airflow/operators/redshift_to_s3_operator.py 
b/airflow/operators/redshift_to_s3_operator.py
index d9ef59d..fda88d9 100644
--- a/airflow/operators/redshift_to_s3_operator.py
+++ b/airflow/operators/redshift_to_s3_operator.py
@@ -93,7 +93,8 @@ class RedshiftToS3Transfer(BaseOperator):
         unload_query = """
                         UNLOAD ('SELECT {0}
                         UNION ALL
-                        SELECT {1} FROM {2}.{3}')
+                        SELECT {1} FROM {2}.{3}
+                        ORDER BY 1 DESC')
                         TO 's3://{4}/{5}/{3}_'
                         with
                         credentials 
'aws_access_key_id={6};aws_secret_access_key={7}'

Reply via email to