-
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
Dynamic information_schema configuration and port more tests #4722
Changes from 1 commit
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 |
---|---|---|
|
@@ -30,91 +30,6 @@ use rstest::rstest; | |
|
||
use super::*; | ||
|
||
#[tokio::test] | ||
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 ported a few tests over to show the behavior -- I will port what else I can from this file as a follow on PR |
||
async fn information_schema_tables_not_exist_by_default() { | ||
let ctx = SessionContext::new(); | ||
|
||
let err = plan_and_collect(&ctx, "SELECT * from information_schema.tables") | ||
.await | ||
.unwrap_err(); | ||
assert_eq!( | ||
err.to_string(), | ||
// Error propagates from SessionState::schema_for_ref | ||
"Error during planning: failed to resolve schema: information_schema" | ||
); | ||
} | ||
|
||
#[tokio::test] | ||
async fn information_schema_tables_no_tables() { | ||
let ctx = | ||
SessionContext::with_config(SessionConfig::new().with_information_schema(true)); | ||
|
||
let result = plan_and_collect(&ctx, "SELECT * from information_schema.tables") | ||
.await | ||
.unwrap(); | ||
|
||
let expected = vec![ | ||
"+---------------+--------------------+-------------+------------+", | ||
"| table_catalog | table_schema | table_name | table_type |", | ||
"+---------------+--------------------+-------------+------------+", | ||
"| datafusion | information_schema | columns | VIEW |", | ||
"| datafusion | information_schema | df_settings | VIEW |", | ||
"| datafusion | information_schema | tables | VIEW |", | ||
"| datafusion | information_schema | views | VIEW |", | ||
"+---------------+--------------------+-------------+------------+", | ||
]; | ||
assert_batches_sorted_eq!(expected, &result); | ||
} | ||
|
||
#[tokio::test] | ||
async fn information_schema_tables_tables_default_catalog() { | ||
let ctx = | ||
SessionContext::with_config(SessionConfig::new().with_information_schema(true)); | ||
|
||
// Now, register an empty table | ||
ctx.register_table("t", table_with_sequence(1, 1).unwrap()) | ||
.unwrap(); | ||
|
||
let result = plan_and_collect(&ctx, "SELECT * from information_schema.tables") | ||
.await | ||
.unwrap(); | ||
|
||
let expected = vec![ | ||
"+---------------+--------------------+-------------+------------+", | ||
"| table_catalog | table_schema | table_name | table_type |", | ||
"+---------------+--------------------+-------------+------------+", | ||
"| datafusion | information_schema | columns | VIEW |", | ||
"| datafusion | information_schema | df_settings | VIEW |", | ||
"| datafusion | information_schema | tables | VIEW |", | ||
"| datafusion | information_schema | views | VIEW |", | ||
"| datafusion | public | t | BASE TABLE |", | ||
"+---------------+--------------------+-------------+------------+", | ||
]; | ||
assert_batches_sorted_eq!(expected, &result); | ||
|
||
// Newly added tables should appear | ||
ctx.register_table("t2", table_with_sequence(1, 1).unwrap()) | ||
.unwrap(); | ||
|
||
let result = plan_and_collect(&ctx, "SELECT * from information_schema.tables") | ||
.await | ||
.unwrap(); | ||
|
||
let expected = vec![ | ||
"+---------------+--------------------+-------------+------------+", | ||
"| table_catalog | table_schema | table_name | table_type |", | ||
"+---------------+--------------------+-------------+------------+", | ||
"| datafusion | information_schema | columns | VIEW |", | ||
"| datafusion | information_schema | df_settings | VIEW |", | ||
"| datafusion | information_schema | tables | VIEW |", | ||
"| datafusion | information_schema | views | VIEW |", | ||
"| datafusion | public | t | BASE TABLE |", | ||
"| datafusion | public | t2 | BASE TABLE |", | ||
"+---------------+--------------------+-------------+------------+", | ||
]; | ||
assert_batches_sorted_eq!(expected, &result); | ||
} | ||
|
||
#[tokio::test] | ||
async fn information_schema_tables_tables_with_multiple_catalogs() { | ||
let ctx = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
|
||
use async_trait::async_trait; | ||
use datafusion::arrow::record_batch::RecordBatch; | ||
use datafusion::prelude::{SessionConfig, SessionContext}; | ||
use datafusion::prelude::SessionContext; | ||
use datafusion_sql::parser::{DFParser, Statement}; | ||
use log::info; | ||
use normalize::convert_batches; | ||
|
@@ -130,12 +130,6 @@ async fn context_for_test_file(file_name: &str) -> SessionContext { | |
setup::register_aggregate_tables(&ctx).await; | ||
ctx | ||
} | ||
"information_schema.slt" => { | ||
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. since this is now controllable dynamically, we do not have to hard code the sqltest runner |
||
info!("Enabling information schema"); | ||
SessionContext::with_config( | ||
SessionConfig::new().with_information_schema(true), | ||
) | ||
} | ||
_ => { | ||
info!("Using default SessionContext"); | ||
SessionContext::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.
The InformationSchema changes are now handed in
update_information_schema