-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly escape query used with Redshift UNLOAD #1907
Correctly escape query used with Redshift UNLOAD #1907
Conversation
@rizzatti, thanks for your PR! By analyzing the history of the files in this pull request, we identified @chenzhan, @ddaniels888 and @steenzout to be potential reviewers. |
Can you add a testcase? |
@Tarrasch I fixed the current testcase.
The quoted query |
Can you get a redshift person to review this? :) |
@Tarrasch, would this help? |
These are the contents of # -*- coding: utf-8 -*-
import os
import luigi
import luigi.contrib.redshift
class RedshiftUnloadExample(luigi.contrib.redshift.RedshiftUnloadTask):
host = os.environ.get('RS_HOST')
user = os.environ.get('RS_USER')
password = os.environ.get('RS_PASS')
database = os.environ.get('RS_DATABASE')
table = os.environ.get('RS_TABLE')
aws_access_key_id = os.environ.get('AWS_ACCESS_KEY_ID')
aws_secret_access_key = os.environ.get('AWS_SECRET_ACCESS_KEY')
s3_unload_path = os.environ.get('RS_UNLOAD_PATH')
# This comes straight from test/contrib/redshift_test.py
def query(self):
return "SELECT 'a' as col_a, current_date as col_b"
if __name__ == '__main__':
luigi.run() |
@rizzatti, I (or any other single volunteering maintainer) cannot be expected to understand details of every system luigi interoperates. Please find another reviewer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't systematically use the UNLOAD
function in my ETL so I haven't tested this myself. But assuming it worked previously and the only case it failed was when '
was used within the unload query, then I don't see anything wrong with this update to escaping '
.
Thanks for review! :) |
Thanks guys. |
Description
SQL queries used in the context of the UNLOAD command in Redshift need to have any single quotes escaped.
This change fixes a little bug which didn't correctly add the backslashes to the query string.
Have you tested this? If so, how?
While creating some jobs that use RedshiftUnloadTask earlier today, I noticed the issue. This PR fixes it.