Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
razeghi71 committed Dec 14, 2023
1 parent 1d942b7 commit a700c2a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions datafusion/sqllogictest/src/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ impl TestContext {
info!("Registering table with many types");
register_table_with_many_types(test_ctx.session_ctx()).await;
}
"explain.slt" => {
info!("Registering table with map");
register_table_with_map(test_ctx.session_ctx()).await;
}
"avro.slt" => {
#[cfg(feature = "avro")]
{
Expand Down Expand Up @@ -268,6 +272,23 @@ pub async fn register_table_with_many_types(ctx: &SessionContext) {
.unwrap();
}

pub async fn register_table_with_map(ctx: &SessionContext) {
let key = Field::new("key", DataType::Int64, false);
let value = Field::new("value", DataType::Int64, true);
let map_field =
Field::new("entries", DataType::Struct(vec![key, value].into()), false);
let fields = vec![
Field::new("int_field", DataType::Int64, true),
Field::new("map_field", DataType::Map(map_field.into(), false), true),
];
let schema = Schema::new(fields);

let memory_table = MemTable::try_new(schema.into(), vec![vec![]]).unwrap();

ctx.register_table("table_with_map", Arc::new(memory_table))
.unwrap();
}

fn table_with_many_types() -> Arc<dyn TableProvider> {
let schema = Schema::new(vec![
Field::new("int32_col", DataType::Int32, false),
Expand Down
4 changes: 4 additions & 0 deletions datafusion/sqllogictest/test_files/explain.slt
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,7 @@ Projection: List([[1, 2, 3], [4, 5, 6]]) AS make_array(make_array(Int64(1),Int64
physical_plan
ProjectionExec: expr=[[[1, 2, 3], [4, 5, 6]] as make_array(make_array(Int64(1),Int64(2),Int64(3)),make_array(Int64(4),Int64(5),Int64(6)))]
--PlaceholderRowExec

# Testing if explain works when we have a filter. The table is registered in test_context.rs: register_table_with_map
statement ok
explain select * from table_with_map where int_field > 0

0 comments on commit a700c2a

Please sign in to comment.