-
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
Changes from all commits
9ccb1f3
45655d7
de57fae
90dc563
2e241a8
221d431
13e914f
68b6cef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -782,7 +782,7 @@ impl DefaultPhysicalPlanner { | |
|
||
Ok(Arc::new(GlobalLimitExec::new(input, limit))) | ||
} | ||
LogicalPlan::CreateExternalTable { .. } => { | ||
LogicalPlan::CreateExternalTable { .. }=> { | ||
// There is no default plan for "CREATE EXTERNAL | ||
// TABLE" -- it must be handled at a higher level (so | ||
// that the appropriate table can be registered with | ||
|
@@ -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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
Ok(Arc::new(EmptyExec::new( | ||
false, | ||
SchemaRef::new(Schema::empty()), | ||
))) | ||
} | ||
LogicalPlan::Explain { .. } => Err(DataFusionError::Internal( | ||
"Unsupported logical plan: Explain must be root of the plan".to_string(), | ||
)), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -687,6 +687,30 @@ async fn select_all() -> Result<()> { | |
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn create_table_as() -> Result<()> { | ||
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 commentThe 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 commentThe 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 |
||
ctx.sql(sql).await.unwrap(); | ||
|
||
let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1"; | ||
let results_all = execute_to_batches(&mut ctx, sql_all).await; | ||
|
||
let expected = vec![ | ||
"+---------+----------------+------+", | ||
"| c1 | c2 | c3 |", | ||
"+---------+----------------+------+", | ||
"| 0.00001 | 0.000000000001 | true |", | ||
"+---------+----------------+------+", | ||
]; | ||
|
||
assert_batches_eq!(expected, &results_all); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn select_distinct() -> Result<()> { | ||
let mut ctx = ExecutionContext::new(); | ||
|
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