-
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
Add support for create table as
via MemTable
#1243
Conversation
create table as
via MemTable
create table as
via MemTablecreate table as
via MemTable
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.
I think it looks great -- thank you @Dandandan !
> create table foo as select * from (values (1,2), (3,4)) as sq;
0 rows in set. Query took 0.007 seconds.
> select * from foo;
+---------+---------+
| column1 | column2 |
+---------+---------+
| 1 | 2 |
| 3 | 4 |
+---------+---------+
@@ -237,6 +240,21 @@ impl ExecutionContext { | |||
Ok(Arc::new(DataFrameImpl::new(self.state.clone(), &plan))) | |||
} | |||
|
|||
LogicalPlan::CreateMemoryTable { input, name } => { |
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.
this is pretty cool
@@ -791,6 +791,13 @@ impl DefaultPhysicalPlanner { | |||
"Unsupported logical plan: CreateExternalTable".to_string(), | |||
)) | |||
} | |||
| LogicalPlan::CreateMemoryTable {..} => { | |||
// Create a dummy exec. |
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.
I think it might make more sense here to throw an error about "unsupported logical plan" -- if we return an EmptyExec
that will result in a plan that does nothing (aka doesn't actually create any tables / table providers) but doesn't error which might be surprising
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.
I tried that before, and it failed I think somehow at the planning stage?
let mut ctx = ExecutionContext::new(); | ||
register_aggregate_simple_csv(&mut ctx).await?; | ||
|
||
let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple"; |
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.
So cool ❤️
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.
one thing you can try is to create table as select from values lists
FYI I pushed 68b6cef to fix a clippy error on your branch |
Thanks! |
thanks @Dandandan this is very cool! |
Which issue does this PR close?
Closes #1213
Rationale for this change
Being able to use syntax:
CREATE TABLE AS SELECT ...
What changes are included in this PR?
Are there any user-facing changes?