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

   `CREATE TABLE t (a, b) AS SELECT 1, 2` failed under `PostgreSqlDialect` and 
`GenericDialect` with `Expected: a data type name, found: ,`, because the list 
after the table name always went through the column definition parser. 
PostgreSQL accepts bare column names there to rename the query's output columns 
([docs](https://www.postgresql.org/docs/current/sql-createtableas.html)).
   
   A new `Dialect::supports_create_table_as_column_names` hook lets 
`parse_create_table` try such a list first and store each name as a `ColumnDef` 
with `DataType::Unspecified`, as `PARTITION OF` already does, so the statement 
renders back unchanged. A bare list without a query remains rejected.
   
   I believe that some other dialects support this syntax, such as Redshift and 
Oracle, but their documentation seems to suggest it comes with some additional 
catches so I will only include Postgres in this first PR.


-- 
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]

  • [PR] PostgreSQL: Support column ... LucaCappelletti94 (via GitHub) via github

Reply via email to