-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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: Workaround for sqlparse issue #652 #17995
fix: Workaround for sqlparse issue #652 #17995
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17995 +/- ##
==========================================
- Coverage 67.05% 66.32% -0.74%
==========================================
Files 1612 1569 -43
Lines 64999 61660 -3339
Branches 6872 6232 -640
==========================================
- Hits 43586 40894 -2692
+ Misses 19546 19167 -379
+ Partials 1867 1599 -268
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
one question, but lgtm otherwise
@@ -41,6 +42,16 @@ | |||
logger = logging.getLogger(__name__) | |||
|
|||
|
|||
# Workaround for https://github.com/andialbrecht/sqlparse/issues/652. | |||
sqlparse.keywords.SQL_REGEX.insert( |
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.
do we not need to replace the erroneous regex?
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.
@etr2460 I guess one could replace it though the position could change. This is a pattern I've used elsewhere where I simply increase the priority of the match by inserting it at the top of the list.
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.
ah, that makes sense. didn't realize the list was prioritized
Oh also, should we consider forking sqlparse to:
cc @betodealmeida @villebro @amitmiran137 who might have thoughts here too |
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.
The change LGTM with some minor nits. It might also be worthwhile considering adding a unit test for this.
superset/sql_parse.py
Outdated
@@ -41,6 +42,16 @@ | |||
logger = logging.getLogger(__name__) | |||
|
|||
|
|||
# Workaround for https://github.com/andialbrecht/sqlparse/issues/652. |
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.
Could we add a TODO:
here to remove when this is fixed upstream and also add a comment in setup.py
where the version is pinned to remove this if it's been fixed?
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.
@villebro there's a unit test already added |
@etr2460 🤦 Right you are, not sure how I missed that. Thanks for setting me straight! |
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.
Approving, as my comments were mostly non-blocking suggestions
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
* fix: Workaround for sqlparse issue apache#652 * Update superset/sql_parse.py Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> * Update sql_parse.py Co-authored-by: John Bodley <john.bodley@airbnb.com> Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
* fix: Workaround for sqlparse issue apache#652 * Update superset/sql_parse.py Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> * Update sql_parse.py Co-authored-by: John Bodley <john.bodley@airbnb.com> Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
SUMMARY
This PR provides a proposed workaround—by way of monkey patching—to andialbrecht/sqlparse#652 which seems to have an incorrect regex pattern when matching single string tokens which contain an escape.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Added unit tests.
ADDITIONAL INFORMATION