Skip to content

Commit

Permalink
sql: add support for CREATE TABLE CLONE (#924)
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>
  • Loading branch information
mobuchowski committed Jul 18, 2022
1 parent 8e65301 commit a34b3a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion integration/sql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,18 @@ fn parse_stmt(stmt: &Statement, context: &mut Context) -> Result<(), String> {
Ok(())
}
Statement::CreateTable {
name, query, like, ..
name, query, like, clone, ..
} => {
if let Some(boxed_query) = query {
parse_query(boxed_query.as_ref(), context)?;
}
if let Some(like_table) = like {
context.add_input(&like_table.to_string());
}
if let Some(clone) = clone {
context.add_input(&clone.to_string());
}

context.add_output(&name.to_string());
Ok(())
}
Expand Down
12 changes: 12 additions & 0 deletions integration/sql/tests/tests_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ fn test_create_table_like() {
)
}

#[test]
fn test_create_table_clone() {
assert_eq!(
test_sql("CREATE OR REPLACE TABLE new CLONE original"),
SqlMeta {
in_tables: table("original"),
out_tables: table("new")
}
)
}


#[test]
fn test_create_and_insert() {
assert_eq!(
Expand Down

0 comments on commit a34b3a3

Please sign in to comment.