You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "funcpp (via GitHub)" <gi...@apache.org> on 2026/03/30 02:05:02 UTC
[PR] Support optional AS keyword in CTE definitions for Databricks [datafusion-sqlparser-rs]
funcpp opened a new pull request, #2286:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2286
## 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
- Disambiguate `name (query)` from `name (columns)` by peeking at the token after `(`
Databricks [allows omitting](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-cte) the `AS` keyword:
```sql
WITH cte (SELECT 1) SELECT * FROM cte
```
## Test plan
- [x] Positive tests: CTE without AS, mixed CTEs, column defs without AS
- [x] Negative test: non-supporting dialects reject the syntax
- [x] Existing CTE tests unaffected
- [x] `cargo fmt`, `cargo clippy`, full test suite pass
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support optional AS keyword in CTE definitions for Databricks [datafusion-sqlparser-rs]
Posted by "funcpp (via GitHub)" <gi...@apache.org>.
funcpp commented on PR #2286:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2286#issuecomment-4174182418
@iffyio Hi! Could you take a look at these Databricks dialect PRs when you have a chance?
- #2286 (CTE without AS)
- #2287 (! operator)
- #2288 (GROUPING SETS bare columns)
- #2289 (multi-column alias)
- #2290 (numeric-prefix identifiers)
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support optional AS keyword in CTE definitions for Databricks [datafusion-sqlparser-rs]
Posted by "yoavcloud (via GitHub)" <gi...@apache.org>.
yoavcloud commented on PR #2286:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2286#issuecomment-4212876346
@funcpp, please address the conflicts and see if my comment makes sense. Otherwise, looks good.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support optional AS keyword in CTE definitions for Databricks [datafusion-sqlparser-rs]
Posted by "funcpp (via GitHub)" <gi...@apache.org>.
funcpp commented on code in PR #2286:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2286#discussion_r3056830207
##########
src/parser/mod.rs:
##########
@@ -14060,7 +14060,7 @@ impl<'a> Parser<'a> {
})
}
- /// Parse a CTE (`alias [( col1, col2, ... )] AS (subquery)`)
+ /// Parse a CTE (`alias [( col1, col2, ... )] [AS] (subquery)`)
Review Comment:
thanks for the review! I merged the AS and column-defs paths, is it better?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support optional AS keyword in CTE definitions for Databricks [datafusion-sqlparser-rs]
Posted by "yoavcloud (via GitHub)" <gi...@apache.org>.
yoavcloud merged PR #2286:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2286
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support optional AS keyword in CTE definitions for Databricks [datafusion-sqlparser-rs]
Posted by "yoavcloud (via GitHub)" <gi...@apache.org>.
yoavcloud commented on code in PR #2286:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2286#discussion_r3056596906
##########
src/parser/mod.rs:
##########
@@ -14060,7 +14060,7 @@ impl<'a> Parser<'a> {
})
}
- /// Parse a CTE (`alias [( col1, col2, ... )] AS (subquery)`)
+ /// Parse a CTE (`alias [( col1, col2, ... )] [AS] (subquery)`)
Review Comment:
If there's a way to remove some duplications in this function, it would be great. It's not critical, though IMO.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org