datafusion-sqlparse/tests
Daniël Heres 15d5f71646
Add CREATE TABLE AS support (#206)
We parse it as a regular `CREATE TABLE` statement
followed by an `AS <query>`, which is how BigQuery works:
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_statement


ANSI SQL and PostgreSQL only support a plain list of columns
after the table name in a CTAS
    `CREATE TABLE t (a) AS SELECT a FROM foo`

We currently only allow specifying a full schema with data
types, or omitting it altogether.

https://www.postgresql.org/docs/12/sql-createtableas.html
https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#as-subquery-clause


Finally, when no schema is specified, we print empty parens after a
plain `CREATE TABLE t ();` as required by PostgreSQL, but skip them
in a CTAS: `CREATE TABLE t AS ...`. This affects serialization only,
the parser allows omitting the schema in a regular `CREATE TABLE` too
since the first release of the parser:
7d27abdfb4/src/sqlparser.rs (L325-L332)

Co-authored-by: Nickolay Ponomarev <asqueella@gmail.com>
2020-06-23 16:30:22 +03:00
..
sqlparser_common.rs Add CREATE TABLE AS support (#206) 2020-06-23 16:30:22 +03:00
sqlparser_mssql.rs Add support for MSSQL's SELECT TOP N syntax (#150) 2020-01-12 23:20:48 -05:00
sqlparser_mysql.rs Add CREATE TABLE AS support (#206) 2020-06-23 16:30:22 +03:00
sqlparser_postgres.rs Add CREATE TABLE AS support (#206) 2020-06-23 16:30:22 +03:00