feat: implement CTEs logic in sqlglot#33518
Merged
betodealmeida merged 1 commit intomasterfrom May 28, 2025
Merged
Conversation
There was a problem hiding this comment.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Missing CTE format validation ▹ view | 🧠 Incorrect |
Files scanned
| File Path | Reviewed |
|---|---|
| superset/sql/parse.py | ✅ |
| superset/db_engine_specs/base.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
9 tasks
45e820e to
73942e2
Compare
f1897ca to
9f04829
Compare
eschutho
approved these changes
May 28, 2025
This was referenced May 28, 2025
3 tasks
LevisNgigi
pushed a commit
to LevisNgigi/superset
that referenced
this pull request
Jun 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Part of #26786, stacked on:
Reimplements the
allows_cte_in_subquerylogic insqlglotfor SIP-117. This is used by MS SQL and Ocient when wrapping a query in the chart builder: if the original query has CTEs they need to be moved from the subquery to the top level of the query.That is, this virtual dataset based off of MS SQL:
When used in a chart becomes:
Note that in theory we could extract just the CTEs to the top-level, building this query:
But since I don't have access to an MS SQL database I opted to preserve the existing behavior. If we ever decide to do that we could add a method
split_ctestoSQLStatementwhich returns CTEs and the main query.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION