-
Notifications
You must be signed in to change notification settings - Fork 14k
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: is_select check for lowercase select with "WITH" clauses #22370
fix: is_select check for lowercase select with "WITH" clauses #22370
Conversation
Checking for token.normalized instead of token.value in is_select check, avoiding issues with lowercase select statements
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.
Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️
We hope to see you in our Slack community 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.
#TIL about .normalized
!
Codecov Report
@@ Coverage Diff @@
## master #22370 +/- ##
=======================================
Coverage 66.87% 66.87%
=======================================
Files 1847 1847
Lines 70561 70561
Branches 7739 7739
=======================================
Hits 47186 47186
Misses 21374 21374
Partials 2001 2001
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
This is great, @fcomuniz!
Would you mind adding a unit test to tests/unit_tests/sql_parse_tests.py
?
I added a lowercase select test to make sure it works correctly |
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.
LGTM, thanks for the fix and the added test case! Ditto on TIL.
@fcomuniz there appears to be a linting issue in your test: |
@villebro, how can i check the linting, is there a tutorial anywhere for running this? Thanks. |
unit test is added, good for merge? @betodealmeida |
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.
Thanks for this fix!
Checking for token.normalized instead of token.value in is_select check, avoiding issues with lowercase select statements
SUMMARY
is_select check in a ParsedQuery object fails to give true response when has multiple WITH clauses, such that sqlparse gives an UNKNOWN type for the query when the statement uses a lowercase "select" clause. This shouldn't happen as lowercase select statements are still select statements
TESTING INSTRUCTIONS
test updating the metadata for a virtual dataset with "WITH" clause at the beginning with lowercase select statements
ADDITIONAL INFORMATION