-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update physical_plan
tests to not use SessionContext
#7243
Changes from all commits
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 |
---|---|---|
|
@@ -1215,7 +1215,6 @@ fn evaluate_group_by( | |
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::execution::context::SessionConfig; | ||
use crate::physical_plan::aggregates::GroupByOrderMode::{ | ||
FullyOrdered, PartiallyOrdered, | ||
}; | ||
|
@@ -1231,7 +1230,6 @@ mod tests { | |
DisplayAs, ExecutionPlan, Partitioning, RecordBatchStream, | ||
SendableRecordBatchStream, Statistics, | ||
}; | ||
use crate::prelude::SessionContext; | ||
use crate::test::exec::{assert_strong_count_converges_to_zero, BlockingExec}; | ||
use crate::test::{assert_is_pending, csv_exec_sorted}; | ||
use crate::{assert_batches_eq, assert_batches_sorted_eq, physical_plan::common}; | ||
|
@@ -1449,8 +1447,7 @@ mod tests { | |
DataType::Int64, | ||
))]; | ||
|
||
let session_ctx = SessionContext::new(); | ||
let task_ctx = session_ctx.task_ctx(); | ||
let task_ctx = Arc::new(TaskContext::default()); | ||
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. This pattern is 95% of this PR: create the |
||
|
||
let partial_aggregate = Arc::new(AggregateExec::try_new( | ||
AggregateMode::Partial, | ||
|
@@ -1556,8 +1553,7 @@ mod tests { | |
DataType::Float64, | ||
))]; | ||
|
||
let session_ctx = SessionContext::new(); | ||
let task_ctx = session_ctx.task_ctx(); | ||
let task_ctx = Arc::new(TaskContext::default()); | ||
|
||
let partial_aggregate = Arc::new(AggregateExec::try_new( | ||
AggregateMode::Partial, | ||
|
@@ -1779,14 +1775,11 @@ mod tests { | |
Arc::new(TestYieldingExec { yield_first: true }); | ||
let input_schema = input.schema(); | ||
|
||
let session_ctx = SessionContext::with_config_rt( | ||
SessionConfig::default(), | ||
Arc::new( | ||
RuntimeEnv::new(RuntimeConfig::default().with_memory_limit(1, 1.0)) | ||
.unwrap(), | ||
), | ||
let runtime = Arc::new( | ||
RuntimeEnv::new(RuntimeConfig::default().with_memory_limit(1, 1.0)).unwrap(), | ||
); | ||
let task_ctx = session_ctx.task_ctx(); | ||
let task_ctx = TaskContext::default().with_runtime(runtime); | ||
let task_ctx = Arc::new(task_ctx); | ||
|
||
let groups_none = PhysicalGroupBy::default(); | ||
let groups_some = PhysicalGroupBy { | ||
|
@@ -1864,8 +1857,7 @@ mod tests { | |
|
||
#[tokio::test] | ||
async fn test_drop_cancel_without_groups() -> Result<()> { | ||
let session_ctx = SessionContext::new(); | ||
let task_ctx = session_ctx.task_ctx(); | ||
let task_ctx = Arc::new(TaskContext::default()); | ||
let schema = | ||
Arc::new(Schema::new(vec![Field::new("a", DataType::Float32, true)])); | ||
|
||
|
@@ -1901,8 +1893,7 @@ mod tests { | |
|
||
#[tokio::test] | ||
async fn test_drop_cancel_with_groups() -> Result<()> { | ||
let session_ctx = SessionContext::new(); | ||
let task_ctx = session_ctx.task_ctx(); | ||
let task_ctx = Arc::new(TaskContext::default()); | ||
let schema = Arc::new(Schema::new(vec![ | ||
Field::new("a", DataType::Float32, true), | ||
Field::new("b", DataType::Float32, true), | ||
|
@@ -1970,8 +1961,7 @@ mod tests { | |
use_coalesce_batches: bool, | ||
is_first_acc: bool, | ||
) -> Result<()> { | ||
let session_ctx = SessionContext::new(); | ||
let task_ctx = session_ctx.task_ctx(); | ||
let task_ctx = Arc::new(TaskContext::default()); | ||
|
||
let (schema, data) = some_data_v2(); | ||
let partition1 = data[0].clone(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,46 +305,10 @@ pub fn concat_batches( | |
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::config::ConfigOptions; | ||
use crate::datasource::MemTable; | ||
use crate::physical_plan::filter::FilterExec; | ||
use crate::physical_plan::{memory::MemoryExec, repartition::RepartitionExec}; | ||
use crate::prelude::SessionContext; | ||
use crate::test::create_vec_batches; | ||
use arrow::datatypes::{DataType, Field, Schema}; | ||
|
||
#[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. These are tests that a config option makes it through to planning SQL, so I moved them to |
||
async fn test_custom_batch_size() -> Result<()> { | ||
let mut config = ConfigOptions::new(); | ||
config.execution.batch_size = 1234; | ||
|
||
let ctx = SessionContext::with_config(config.into()); | ||
let plan = create_physical_plan(ctx).await?; | ||
let coalesce = plan.as_any().downcast_ref::<CoalesceBatchesExec>().unwrap(); | ||
assert_eq!(1234, coalesce.target_batch_size); | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_disable_coalesce() -> Result<()> { | ||
let mut config = ConfigOptions::new(); | ||
config.execution.coalesce_batches = false; | ||
|
||
let ctx = SessionContext::with_config(config.into()); | ||
let plan = create_physical_plan(ctx).await?; | ||
let _filter = plan.as_any().downcast_ref::<FilterExec>().unwrap(); | ||
Ok(()) | ||
} | ||
|
||
async fn create_physical_plan(ctx: SessionContext) -> Result<Arc<dyn ExecutionPlan>> { | ||
let schema = test_schema(); | ||
let partition = create_vec_batches(&schema, 10); | ||
let table = MemTable::try_new(schema, vec![partition])?; | ||
ctx.register_table("a", Arc::new(table))?; | ||
let dataframe = ctx.sql("SELECT * FROM a WHERE c0 < 1").await?; | ||
dataframe.create_physical_plan().await | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn test_concat_batches() -> Result<()> { | ||
let schema = test_schema(); | ||
|
@@ -385,10 +349,9 @@ mod tests { | |
// execute and collect results | ||
let output_partition_count = exec.output_partitioning().partition_count(); | ||
let mut output_partitions = Vec::with_capacity(output_partition_count); | ||
let session_ctx = SessionContext::new(); | ||
for i in 0..output_partition_count { | ||
// execute this *output* partition and collect all batches | ||
let task_ctx = session_ctx.task_ctx(); | ||
let task_ctx = Arc::new(TaskContext::default()); | ||
let mut stream = exec.execute(i, task_ctx.clone())?; | ||
let mut batches = vec![]; | ||
while let Some(result) = stream.next().await { | ||
|
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 point of this PR is to remove these dependencies