-
Notifications
You must be signed in to change notification settings - Fork 14.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
Fix Redshift unload query when select query contains single quotes #30300
Fix Redshift unload query when select query contains single quotes #30300
Conversation
The test failure is not related to this change:
It was fixed by @potiuk in #29395, but it seems like prod image doesn't consider this fix. |
Looks like a flaky test actually. |
How this change would behave with queries already using double quotes? I know there had been many questions about this issue on Slack and the usual recommendation is to use double quotes. My guess is it wont work (I might be wrong). One solution would to detect if the string uses double quotes and if it does, no need to use Besides that, thanks for trying to find a solution to this problem because, as mentioned, it had been brought up a lot on Slack |
@vincbeck I'll test it with double quotes and if that doesn't work I'll implement your interesting suggestion. |
@vincbeck I tested it and I had a problem, so I added a check as you proposed with a warning, we can remove this check in the next major release, can you check it now? |
@@ -143,8 +144,17 @@ def __init__( | |||
def _build_unload_query( | |||
self, credentials_block: str, select_query: str, s3_key: str, unload_options: str | |||
) -> str: | |||
# TODO: remove in provider 8.0.0 | |||
if "''" in select_query: | |||
logging.warning( |
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.
Why do you want to remove this check at the next major release? I dont understand. Users, at any point in time, can use this operator and specify a query with already double quoted strings
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.
+1
Users may stumble on this in the future after you have removed the check.
Also is it possible the string contains some double quotes but not everywhere? Do we want to try handle these half working situations? This type of string sanitization code can often get very hairy very quick. Is there a thirdparty library we can use instead which specializes in this?
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 dont know any library doing that but that'd be cool. Otherwise, I am in favor of NOT managing these kind of use cases. These use cases (mix of quotes escaped and some unescaped) are not valid and users should fix it. The current implementation would not alter the string which, I think, is the correct behavior
I just added a comment about it. Something is not clear to me |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
closes: #30287
This PR fixes the Redshift unload query when the select query contains quotes, by replacing
'
by$$
. There is an alternative solution described in Redshift unload doc, which is duplicating the single quotes:But I'm using
$$
in my queries and it works fine