-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
chore: Remove references from SessionState from physical_plan #5455
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
use crate::datasource::file_format::file_type::FileCompressionType; | ||
use crate::error::{DataFusionError, Result}; | ||
use crate::execution::context::{SessionState, TaskContext}; | ||
use crate::execution::context::TaskContext; | ||
use crate::physical_plan::expressions::PhysicalSortExpr; | ||
use crate::physical_plan::file_format::file_stream::{ | ||
FileOpenFuture, FileOpener, FileStream, | ||
|
@@ -280,7 +280,7 @@ impl FileOpener for CsvOpener { | |
} | ||
|
||
pub async fn plan_to_csv( | ||
state: &SessionState, | ||
task_ctx: Arc<TaskContext>, | ||
plan: Arc<dyn ExecutionPlan>, | ||
path: impl AsRef<str>, | ||
) -> Result<()> { | ||
|
@@ -300,8 +300,7 @@ pub async fn plan_to_csv( | |
let path = fs_path.join(filename); | ||
let file = fs::File::create(path)?; | ||
let mut writer = csv::Writer::new(file); | ||
let task_ctx = Arc::new(TaskContext::from(state)); | ||
let stream = plan.execute(i, task_ctx)?; | ||
let stream = plan.execute(i, task_ctx.clone())?; | ||
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. Note that so making it once and cloning is probably better than making multiple |
||
|
||
let handle: JoinHandle<Result<()>> = task::spawn(async move { | ||
stream | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ use crate::physical_plan::file_format::FileMeta; | |
use crate::{ | ||
datasource::listing::FileRange, | ||
error::{DataFusionError, Result}, | ||
execution::context::{SessionState, TaskContext}, | ||
execution::context::TaskContext, | ||
physical_optimizer::pruning::PruningPredicate, | ||
physical_plan::{ | ||
expressions::PhysicalSortExpr, | ||
|
@@ -704,7 +704,7 @@ impl ParquetFileReaderFactory for DefaultParquetFileReaderFactory { | |
|
||
/// Executes a query and writes the results to a partitioned Parquet file. | ||
pub async fn plan_to_parquet( | ||
state: &SessionState, | ||
task_ctx: Arc<TaskContext>, | ||
plan: Arc<dyn ExecutionPlan>, | ||
path: impl AsRef<str>, | ||
writer_properties: Option<WriterProperties>, | ||
|
@@ -726,8 +726,7 @@ pub async fn plan_to_parquet( | |
let file = fs::File::create(path)?; | ||
let mut writer = | ||
ArrowWriter::try_new(file, plan.schema(), writer_properties.clone())?; | ||
let task_ctx = Arc::new(TaskContext::from(state)); | ||
let stream = plan.execute(i, task_ctx)?; | ||
let stream = plan.execute(i, task_ctx.clone())?; | ||
let handle: tokio::task::JoinHandle<Result<()>> = | ||
tokio::task::spawn(async move { | ||
stream | ||
|
@@ -803,6 +802,7 @@ mod tests { | |
use crate::datasource::file_format::test_util::scan_format; | ||
use crate::datasource::listing::{FileRange, PartitionedFile}; | ||
use crate::datasource::object_store::ObjectStoreUrl; | ||
use crate::execution::context::SessionState; | ||
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 is for tests, which I think is ok to depend on datafusion core |
||
use crate::execution::options::CsvReadOptions; | ||
use crate::physical_plan::displayable; | ||
use crate::physical_plan::file_format::partition_type_wrap; | ||
|
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 the pR is to remove the use of SessionState and hoist the creation of
TaskContext
intoSessionContext