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

chore: organize SQL parsing files #30258

Merged
merged 1 commit into from
Sep 13, 2024
Merged

chore: organize SQL parsing files #30258

merged 1 commit into from
Sep 13, 2024

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Sep 12, 2024

SUMMARY

Move the SQLScript, SQLStatement, and related functions that use sqlglot to a new directory superset/sql/, since the superset/sql_parse.py file is getting big. This was suggested by @mistercrunch on the discussion about SIP-117.

The goal with SIP-117 is to have all SQL parsing living in superset/sql/ and using sqlglot, and get rid of sql_parse.py.

I also split the unit tests from tests/unit_tests/sql_parse_tests.py to tests/unit_tests/sql/parse_tests.py, and in the process I converted some of the old ParsedQuery.tables tests to the new extract_tables_from_statement function.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@github-actions github-actions bot added the api Related to the REST API label Sep 12, 2024
@dosubot dosubot bot added the sqllab Namespace | Anything related to the SQL Lab label Sep 12, 2024
@betodealmeida betodealmeida force-pushed the organize-sql-files branch 2 times, most recently from 63813b1 to 163feb4 Compare September 12, 2024 20:28
@@ -63,7 +63,8 @@
from superset.databases.utils import get_table_metadata, make_url_safe
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
from superset.exceptions import DisallowedSQLFunction, OAuth2Error, OAuth2RedirectError
from superset.sql_parse import ParsedQuery, SQLScript, Table
from superset.sql.parse import SQLScript, Table
from superset.sql_parse import ParsedQuery
Copy link
Member

Choose a reason for hiding this comment

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

nit, but these two paths are really similar. What's the difference between them and will people be able to remember what goes where?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, sorry, I forgot to mention that the goal is to get rid of sql_parse.py.

The new superset/sql/ directory will use only sqlglot, and as I'm working on SIP-117 I'm taking sqlparse logic from sql_parse.py and reimplementing it using sqlglot in sql/parse/.

Copy link
Member

Choose a reason for hiding this comment

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

ok, perfect, that makes sense, then.

Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

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

LGTM!

@betodealmeida betodealmeida merged commit bdf29cb into master Sep 13, 2024
35 checks passed
@rusackas rusackas deleted the organize-sql-files branch September 16, 2024 17:17
@sadpandajoe sadpandajoe added the v4.1 Label added by the release manager to track PRs to be included in the 4.1 branch label Sep 30, 2024
sadpandajoe pushed a commit that referenced this pull request Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the REST API preset-io size/XXL sqllab Namespace | Anything related to the SQL Lab v4.1 Label added by the release manager to track PRs to be included in the 4.1 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants