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: downgrade sqlparse and add unit test #10165

Merged
merged 2 commits into from Jul 6, 2020

Conversation

bkyryliuk
Copy link
Member

@bkyryliuk bkyryliuk commented Jun 25, 2020

SUMMARY

Downgrade sqlparse library to 0.3.0

Reported bug in sqlparse as well: andialbrecht/sqlparse#562

0.3.1 has a bug and reindentation converts [removes the space]

extract(HOUR from from_unixtime(hour_ts) AT TIME ZONE 'America/Los_Angeles')

into

extract(HOUR **fromfrom_unixtime(hour_ts)** AT TIME ZONE 'America/Los_Angeles')

Partially reverts: https://github.com/apache/incubator-superset/pull/9786/files (sqlparse bump and the test)

TEST PLAN

unit tests and local deployment

ADDITIONAL INFORMATION

[x] Bug Fix

@bkyryliuk bkyryliuk marked this pull request as draft June 25, 2020 17:16
@bkyryliuk bkyryliuk force-pushed the bogdan/fix_sqlparse_bug branch 4 times, most recently from e4d8a5b to 882598f Compare June 25, 2020 18:18
@bkyryliuk bkyryliuk marked this pull request as ready for review June 25, 2020 18:44
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.

setup.py needs to also be updated to reflect this. I'm assuming for now setup.py will pin to sqlparse==0.3.0. Next to the pinned version I would also add a comment why this is pinned, and a link to the issue to make sure we can safely unpin it once it is resolved.

@@ -187,7 +189,8 @@ def test_select_if(self):
# SHOW TABLES ((FROM | IN) qualifiedName)? (LIKE pattern=STRING)?
def test_show_tables(self):
query = "SHOW TABLES FROM s1 like '%order%'"
self.assertEqual(set(), self.extract_tables(query))
# TODO: figure out what should code do here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I bumped from 0.3.0 to 0.3.1, the comments and the test case weren't super clear to me. It would be more transparent to state that this test should return an empty set, but on version 0.3.0 it incorrectly returns the database/schema name. Also it would be good to include the expected true test case here commented out, so that the next person knows that the test is expected to fail now, but commenting out the true case should work when bumping to >=0.3.2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@john-bodley
Copy link
Member

I’m sure there were a number of fixes in 0.3.1. I wonder if anyone has any sense on what regressions would be introduction by downgrading. I guess we could look at the sqlparse changelog.

@bkyryliuk bkyryliuk force-pushed the bogdan/fix_sqlparse_bug branch 2 times, most recently from 0702b8f to 0ac1478 Compare June 26, 2020 16:35
@bkyryliuk
Copy link
Member Author

@villebro addressed the comments, thanks!
@john-bodley 0.36 version used sqlparse 0.3.0 as I remember,
https://sqlparse.readthedocs.io/en/latest/changes/ - shows some bugfixes and improvements, however I am not familiar on how they related to superset bugs. https://github.com/apache/incubator-superset/pull/9786/files doesn't seem to be mentioned in any superset issues.

@john-bodley
Copy link
Member

Looking at the changelog I suspect this commit (related to comments) is probably the biggest contender for a regression in terms of table extraction, though it's likely to be low.

@bkyryliuk
Copy link
Member Author

@villebro , @john-bodley how would you prefer to proceed here? We've downgraded to 0.30 @ dropbox, I would suggest to do the same for the upcoming 0.37 release.

@villebro
Copy link
Member

villebro commented Jul 3, 2020

It is my understanding that the bug you uncovered in 0.3.1 is more serious than the one that I know of in 0.3.0, from the perspective of Superset anyway. Therefore I believe the best course of action is to merge this.

setup.py Outdated
@@ -105,7 +105,7 @@ def get_git_sha():
"slackclient>=2.6.2",
"sqlalchemy>=1.3.16, <2.0",
"sqlalchemy-utils>=0.36.6,<0.37",
"sqlparse>=0.3.0, <0.4",
"sqlparse==0.3.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment right here as to why it's pinned? Maybe a link to an issue on the lib's Github (if any) or to this PR if that's the best option

"sqlparse==0.3.0",  # PINNED! see PR #10165

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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, but I suggest adding the comment raised by @mistercrunch as to why it's currently pinned

@bkyryliuk bkyryliuk merged commit b7c45fe into apache:master Jul 6, 2020
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* Downgrade sqlparse and add unit test

* Explain why sqlparse is pinned

Co-authored-by: bogdan kyryliuk <bogdankyryliuk@dropbox.com>
@villebro villebro mentioned this pull request Mar 11, 2022
9 tasks
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.37.0 labels Mar 12, 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 v0.37 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants