alrevuelta opened a new pull request, #2333:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2333

   Fixes #2221.
   
   ClickHouse's `WITH` clause supports a reversed-order form `<expression> AS 
<identifier>` (alongside, and freely interleaved with, traditional CTEs). 
Currently the parser hard-errors on the leading non-identifier token:
   
   ```
   WITH 42 AS answer SELECT answer FROM t
   -- Expected: identifier, found: 42
   ```
   
   ## Changes
   
   - New `WithItem` enum (`Cte(Cte)` | `Named { expr, alias }`); 
`With::cte_tables: Vec<Cte>` becomes `With::items: Vec<WithItem>`.
   - New dialect flag `Dialect::supports_with_clause_scalar_expression` 
(default `false`, `true` for `ClickHouseDialect` only).
   - New `parse_with_item` routes each WITH-list element: when the leading 
token can't begin a CTE name, it parses `<expr> AS <ident>` directly; otherwise 
it tries the CTE form via `maybe_parse` and falls back. `parse_cte` itself is 
unchanged.
   
   ## Tests
   
   Added in `tests/sqlparser_clickhouse.rs`, covering: literal scalar (the 
issue's example), string literal, aggregate, scalar subquery, bare-identifier 
disambiguation, mixing scalar + CTE in one list, lambda, and a negative test 
confirming non-ClickHouse dialects still reject the form.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to