Skip to content

fix(splitter): handle CTE inside CREATE VIEW statements#708

Open
psteinroe wants to merge 2 commits intomainfrom
fix/splitter-error
Open

fix(splitter): handle CTE inside CREATE VIEW statements#708
psteinroe wants to merge 2 commits intomainfrom
fix/splitter-error

Conversation

@psteinroe
Copy link
Collaborator

Summary

  • Fixes the statement splitter incorrectly splitting CREATE OR REPLACE VIEW ... AS WITH cte AS (...) SELECT ... into two statements at the SELECT keyword
  • When WITH_KW is excluded (inside a CREATE statement) and followed by an identifier or RECURSIVE, the splitter now delegates to the CTE parser so the following DML keyword is consumed as part of the same statement
  • Adds test cases for CREATE VIEW with CTE and CREATE TABLE with storage parameters (WITH (fillfactor=70))

Closes #135

Test plan

  • Added create_view_with_cte__1.sql test — verifies the reported bug is fixed
  • Added create_table_with_storage__1.sql test — verifies non-CTE WITH in CREATE is not affected
  • All existing splitter tests pass

🤖 Generated with Claude Code

psteinroe and others added 2 commits March 5, 2026 10:28
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Statement Splitter

1 participant