fix(splitter): handle CTE inside CREATE VIEW statements#708
Open
fix(splitter): handle CTE inside CREATE VIEW statements#708
Conversation
The splitter incorrectly split `CREATE VIEW ... AS WITH cte AS (...) SELECT ...` into two statements at the `SELECT` keyword after the CTE closing parenthesis. When WITH_KW is excluded (inside CREATE), detect CTE patterns and parse them properly so the following DML keyword is not treated as a new statement. Closes #135 Co-Authored-By: Claude Opus 4.6 <[email protected]>
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
CREATE OR REPLACE VIEW ... AS WITH cte AS (...) SELECT ...into two statements at theSELECTkeywordWITH_KWis excluded (inside a CREATE statement) and followed by an identifier orRECURSIVE, the splitter now delegates to the CTE parser so the following DML keyword is consumed as part of the same statementCREATE VIEWwith CTE andCREATE TABLEwith storage parameters (WITH (fillfactor=70))Closes #135
Test plan
create_view_with_cte__1.sqltest — verifies the reported bug is fixedcreate_table_with_storage__1.sqltest — verifies non-CTEWITHin CREATE is not affected🤖 Generated with Claude Code