-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support CREATE OR REPLACE TABLE #2613
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AssHero Thanks for your work 👍
Maybe you can add some test like
https://github.com/apache/arrow-datafusion/blob/0c4ffd4f7b064a8f4e4a167e2e4c913389056968/datafusion/core/tests/sql/create_drop.rs#L22-L46
ok, i'll add some test cases |
'create or replace if not exists' is not supported in MySQL/PG, and is not permitted in databricks. |
Thanks for the contribution @AssHero. I also would like to see |
…OT EXISTS' coexist with 'REPLACE'
I'll separate the 'IF NOT EXISTS' and 'OR REPLACE', and report the error if both specified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great -- thank you @AssHero, @Ted-Jiang and @waynexia
Which issue does this PR close?
Closes #2605
Rationale for this change
replace the table content if table already exits
❯ create table xx as values(1,2),(3,4);
+---------+---------+
| column1 | column2 |
+---------+---------+
| 1 | 2 |
| 3 | 4 |
+---------+---------+
2 rows in set. Query took 0.004 seconds.
❯ create or replace table xx as values(5,6);
+---------+---------+
| column1 | column2 |
+---------+---------+
| 5 | 6 |
+---------+---------+
1 row in set. Query took 0.004 seconds.
if 'if not exists' and 'or replace' are both specified, treat as 'or replace'
❯ create or replace table if not exists xx as values(7,8);
+---------+---------+
| column1 | column2 |
+---------+---------+
| 7 | 8 |
+---------+---------+
1 row in set. Query took 0.002 seconds.
What changes are included in this PR?
adjust rules for create table in context.rs