Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmturner committed Apr 4, 2022
1 parent 64f6ba6 commit 279b906
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
23 changes: 23 additions & 0 deletions datafusion/core/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3248,6 +3248,29 @@ mod tests {
Ok(())
}

#[tokio::test]
async fn sql_create_catalog() -> Result<()> {
// the information schema used to introduce cyclic Arcs
let ctx = SessionContext::with_config(
SessionConfig::new().with_information_schema(true),
);

// Create schema
ctx.sql("CREATE DATABASE test").await?.collect().await?;

// Add table to schema
ctx.sql("CREATE TABLE test.abc.y AS VALUES (1,2,3)")
.await?
.collect()
.await?;

// Check table exists in schema
let results = ctx.sql("SELECT * FROM information_schema.tables WHERE table_catalog='test' AND table_schema='abc' AND table_name = 'y'").await.unwrap().collect().await.unwrap();

assert_eq!(results[0].num_rows(), 1);
Ok(())
}

#[tokio::test]
async fn normalized_column_identifiers() {
// create local execution context
Expand Down
6 changes: 3 additions & 3 deletions datafusion/core/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub struct CreateExternalTable {
pub struct CreateCatalogSchema {
/// The table schema
pub schema_name: String,
/// The table name
/// Do nothing (except issuing a notice) if a schema with the same name already exists
pub if_not_exists: bool,
/// Empty schema
pub schema: DFSchemaRef,
Expand All @@ -202,9 +202,9 @@ pub struct CreateCatalogSchema {
/// Creates a catalog.
#[derive(Clone)]
pub struct CreateCatalog {
/// The table schema
/// The catalog name
pub catalog_name: String,
/// The table name
/// Do nothing (except issuing a notice) if a schema with the same name already exists
pub if_not_exists: bool,
/// Empty schema
pub schema: DFSchemaRef,
Expand Down

0 comments on commit 279b906

Please sign in to comment.