-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Is your feature request related to a problem or challenge?
At the moment, the CREATE EXTERNAL TABLE command requires all clauses in an exact order: https://arrow.apache.org/datafusion/user-guide/sql/ddl.html#create-external-table
So this is great:
CREATE EXTERNAL TABLE test
STORED AS CSV
WITH HEADER ROW
LOCATION '/path/to/directory/of/files';However, generates a somewhat confusing syntax error:
CREATE EXTERNAL TABLE test
WITH HEADER ROW
STORED AS CSV
LOCATION '/path/to/directory/of/files'; 🤔 Invalid statement: sql parser error: Expected STORED, found: WITH
I think #6247 will help but we can do better
Describe the solution you'd like
I would like to extend the CREATE EXTERNAL TABLE syntax parser so the various clauses can be provided in any order and people don't have to put them in a specific order
Aka I want this (and similar) to work:
CREATE EXTERNAL TABLE test
WITH HEADER ROW
STORED AS CSV
LOCATION '/path/to/directory/of/files';parser code is here: https://github.com/apache/arrow-datafusion/blob/main/datafusion/sql/src/parser.rs
There is an example of doing similar things in sqlparser-rs for CREATE FUNCTION: https://github.com/sqlparser-rs/sqlparser-rs/blob/b29b551fa111bbd50c40568f6aea6c49eafc0b9c/src/parser.rs#L2673-L2702
Describe alternatives you've considered
No response
Additional context
I am trying to help here: #6247
I struggled with this syntax while trying to port some sqllogictests: #6234