Skip to content

Support optional AS keyword in CTE definitions for Databricks#2286

Open
funcpp wants to merge 1 commit intoapache:mainfrom
funcpp:support-cte-without-as-databricks
Open

Support optional AS keyword in CTE definitions for Databricks#2286
funcpp wants to merge 1 commit intoapache:mainfrom
funcpp:support-cte-without-as-databricks

Conversation

@funcpp
Copy link
Copy Markdown
Contributor

@funcpp funcpp commented Mar 30, 2026

Summary

  • Add Dialect::supports_cte_without_as() to support dialects where the AS keyword is optional in CTE definitions
  • Enable for Databricks and Generic dialects
  • Use maybe_parse to disambiguate name (query) from name (columns), following the same pattern as IN subquery/list disambiguation

Databricks allows omitting the AS keyword:

WITH cte (SELECT 1) SELECT * FROM cte

Test plan

  • Positive tests: CTE without AS, mixed CTEs, column defs without AS
  • Negative test: non-supporting dialects reject the syntax
  • Existing CTE tests unaffected
  • cargo fmt, cargo clippy, full test suite pass

@funcpp funcpp force-pushed the support-cte-without-as-databricks branch from 2be0e8d to 90111a4 Compare March 30, 2026 02:12
Databricks allows omitting the AS keyword in CTE definitions:
`WITH cte (SELECT ...) SELECT * FROM cte`

Add `supports_cte_without_as()` dialect method and enable it for
Databricks and Generic dialects.
@funcpp funcpp force-pushed the support-cte-without-as-databricks branch from 90111a4 to 2051de9 Compare March 30, 2026 02:18
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.

1 participant