Skip to content
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

Conversation

fcomuniz
Copy link
Contributor

@fcomuniz fcomuniz commented Dec 8, 2022

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

Checking for token.normalized instead of token.value in is_select check, avoiding issues with lowercase select statements
Copy link
Contributor

@github-actions github-actions bot left a 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!

Copy link
Member

@betodealmeida betodealmeida left a 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
Copy link

codecov bot commented Dec 8, 2022

Codecov Report

Merging #22370 (221295e) into master (f64423a) will not change coverage.
The diff coverage is n/a.

@@           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           
Flag Coverage Δ
hive 52.53% <ø> (ø)
mysql 77.95% <ø> (ø)
postgres 78.02% <ø> (ø)
presto 52.42% <ø> (ø)
python 81.23% <ø> (ø)
sqlite 76.48% <ø> (ø)
unit 50.91% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/sql_parse.py 96.49% <ø> (ø)
superset/models/core.py 90.50% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@betodealmeida betodealmeida left a 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?

@pull-request-size pull-request-size bot added size/S and removed size/XS labels Dec 8, 2022
@fcomuniz
Copy link
Contributor Author

fcomuniz commented Dec 8, 2022

I added a lowercase select test to make sure it works correctly

Copy link
Member

@villebro villebro left a 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.

@villebro
Copy link
Member

villebro commented Dec 9, 2022

@fcomuniz there appears to be a linting issue in your test:
image

@fcomuniz
Copy link
Contributor Author

fcomuniz commented Dec 9, 2022

@villebro, how can i check the linting, is there a tutorial anywhere for running this?

Thanks.

@mayurnewase
Copy link
Contributor

unit test is added, good for merge? @betodealmeida

Copy link
Member

@betodealmeida betodealmeida left a 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!

@betodealmeida betodealmeida merged commit e9b4022 into apache:master Apr 18, 2023
sebastianliebscher pushed a commit to sebastianliebscher/superset that referenced this pull request Apr 28, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/S 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants