Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CREATE EXTERNAL TABLE more user friendly #6248

Closed
alamb opened this issue May 5, 2023 · 1 comment · Fixed by #6257
Closed

Make CREATE EXTERNAL TABLE more user friendly #6248

alamb opened this issue May 5, 2023 · 1 comment · Fixed by #6257
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@alamb
Copy link
Contributor

alamb commented May 5, 2023

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

@alamb alamb added enhancement New feature or request good first issue Good for newcomers labels May 5, 2023
@aprimadi
Copy link
Contributor

aprimadi commented May 6, 2023

Currently working on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants