Skip to content

Commit

Permalink
Add tests for create table
Browse files Browse the repository at this point in the history
  • Loading branch information
OussamaSaoudi committed Sep 29, 2024
1 parent 170f239 commit 88e90d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions datafusion/core/src/catalog_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ pub fn resolve_table_references(
DFStatement::CreateExternalTable(table) => {
let idents: Vec<Ident> = table.name.split('.').map(Ident::from).collect();
visitor.relations.insert(ObjectName(idents));
visitor
.relations
.insert(ObjectName(vec![Ident::from(table.name.as_str())]));
}
DFStatement::CopyTo(CopyToStatement { source, .. }) => match source {
CopyToSource::Relation(table_name) => {
Expand Down
9 changes: 8 additions & 1 deletion datafusion/sql/tests/sql_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,13 @@ fn create_external_table_with_pk() {
quick_test(sql, expected);
}

#[test]
fn create_external_table_wih_schema() {
let sql = "CREATE EXTERNAL TABLE staging.foo STORED AS CSV LOCATION 'foo.csv'";
let expected = "CreateExternalTable: Partial { schema: \"staging\", table: \"foo\" }";
quick_test(sql, expected);
}

#[test]
fn create_schema_with_quoted_name() {
let sql = "CREATE SCHEMA \"quoted_schema_name\"";
Expand Down Expand Up @@ -1949,7 +1956,7 @@ fn create_external_table_csv_no_schema() {
}

#[test]
fn create_external_table_with_compression_type() {
fn create_external_table_with_compression_typet() {
// positive case
let sqls = vec![
"CREATE EXTERNAL TABLE t(c1 int) STORED AS CSV LOCATION 'foo.csv.gz' OPTIONS ('format.compression' 'gzip')",
Expand Down

0 comments on commit 88e90d2

Please sign in to comment.