-
Notifications
You must be signed in to change notification settings - Fork 454
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: upgrade to DataFusion 46.0.0 (WORK IN PROGRESS) #3261
Draft
alamb
wants to merge
2
commits into
delta-io:main
Choose a base branch
from
alamb:alamb/df_46
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+138
−122
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ resolver = "2" | |
|
||
[workspace.package] | ||
authors = ["Qingping Hou <[email protected]>"] | ||
rust-version = "1.81" | ||
rust-version = "1.82" | ||
keywords = ["deltalake", "delta", "datalake"] | ||
readme = "README.md" | ||
edition = "2021" | ||
|
@@ -45,16 +45,28 @@ object_store = { version = "0.11.2" , features = ["cloud"]} | |
parquet = { version = "54" } | ||
|
||
# datafusion | ||
datafusion = "45" | ||
datafusion-expr = "45" | ||
datafusion-common = "45" | ||
datafusion-ffi = "45" | ||
datafusion-functions = "45" | ||
datafusion-functions-aggregate = "45" | ||
datafusion-physical-expr = "45" | ||
datafusion-physical-plan = "45" | ||
datafusion-proto = "45" | ||
datafusion-sql = "45" | ||
# datafusion = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/core" } | ||
# datafusion-expr = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/expr" } | ||
# datafusion-common = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/common" } | ||
# datafusion-ffi = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/ffi" } | ||
# datafusion-functions = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/functions" } | ||
# datafusion-functions-aggregate = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/functions-aggregate" } | ||
# datafusion-physical-expr = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/physical-expr" } | ||
# datafusion-physical-plan = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/physical-plan" } | ||
# datafusion-proto = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/proto" } | ||
# datafusion-sql = { path = "/Users/andrewlamb/Software/datafusion2/datafusion/sql" } | ||
|
||
|
||
datafusion = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
datafusion-expr = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
datafusion-ffi = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
datafusion-functions = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
datafusion-functions-aggregate = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
datafusion-physical-expr = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
datafusion-physical-plan = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
datafusion-proto = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
datafusion-sql = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2fd558fdd0fa95e70d6ae5135776d164119f3536" } | ||
|
||
# serde | ||
serde = { version = "1.0.194", features = ["derive"] } | ||
|
@@ -77,4 +89,3 @@ async-trait = { version = "0.1" } | |
futures = { version = "0.3" } | ||
tokio = { version = "1" } | ||
num_cpus = { version = "1" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,9 +39,8 @@ use async_trait::async_trait; | |
use chrono::{DateTime, TimeZone, Utc}; | ||
use datafusion::catalog::{Session, TableProviderFactory}; | ||
use datafusion::config::TableParquetOptions; | ||
use datafusion::datasource::physical_plan::parquet::ParquetExecBuilder; | ||
use datafusion::datasource::physical_plan::{ | ||
wrap_partition_type_in_dict, wrap_partition_value_in_dict, FileScanConfig, | ||
wrap_partition_type_in_dict, wrap_partition_value_in_dict, FileScanConfig, ParquetSource, | ||
}; | ||
use datafusion::datasource::{listing::PartitionedFile, MemTable, TableProvider, TableType}; | ||
use datafusion::execution::context::{SessionConfig, SessionContext, SessionState, TaskContext}; | ||
|
@@ -648,36 +647,39 @@ impl<'a> DeltaScanBuilder<'a> { | |
..Default::default() | ||
}; | ||
|
||
let mut exec_plan_builder = ParquetExecBuilder::new( | ||
FileScanConfig::new(self.log_store.object_store_url(), file_schema) | ||
.with_file_groups( | ||
// If all files were filtered out, we still need to emit at least one partition to | ||
// pass datafusion sanity checks. | ||
// | ||
// See https://github.com/apache/datafusion/issues/11322 | ||
if file_groups.is_empty() { | ||
vec![vec![]] | ||
} else { | ||
file_groups.into_values().collect() | ||
}, | ||
) | ||
.with_statistics(stats) | ||
.with_projection(self.projection.cloned()) | ||
.with_limit(self.limit) | ||
.with_table_partition_cols(table_partition_cols), | ||
) | ||
.with_schema_adapter_factory(Arc::new(DeltaSchemaAdapterFactory {})) | ||
.with_table_parquet_options(parquet_options); | ||
let mut file_source = ParquetSource::new(parquet_options) | ||
.with_schema_adapter_factory(Arc::new(DeltaSchemaAdapterFactory {})); | ||
|
||
// Sometimes (i.e Merge) we want to prune files that don't make the | ||
// filter and read the entire contents for files that do match the | ||
// filter | ||
if let Some(predicate) = logical_filter { | ||
if config.enable_parquet_pushdown { | ||
exec_plan_builder = exec_plan_builder.with_predicate(predicate); | ||
file_source = file_source.with_predicate(Arc::clone(&file_schema), predicate); | ||
} | ||
}; | ||
|
||
let file_scan_config = FileScanConfig::new( | ||
self.log_store.object_store_url(), | ||
file_schema, | ||
Arc::new(file_source), | ||
) | ||
.with_file_groups( | ||
// If all files were filtered out, we still need to emit at least one partition to | ||
// pass datafusion sanity checks. | ||
// | ||
// See https://github.com/apache/datafusion/issues/11322 | ||
if file_groups.is_empty() { | ||
vec![vec![]] | ||
} else { | ||
file_groups.into_values().collect() | ||
}, | ||
) | ||
.with_statistics(stats) | ||
.with_projection(self.projection.cloned()) | ||
.with_limit(self.limit) | ||
.with_table_partition_cols(table_partition_cols); | ||
|
||
let metrics = ExecutionPlanMetricsSet::new(); | ||
MetricBuilder::new(&metrics) | ||
.global_counter("files_scanned") | ||
|
@@ -688,7 +690,7 @@ impl<'a> DeltaScanBuilder<'a> { | |
|
||
Ok(DeltaScan { | ||
table_uri: ensure_table_uri(self.log_store.root_uri())?.as_str().into(), | ||
parquet_scan: exec_plan_builder.build_arc(), | ||
parquet_scan: file_scan_config.build(), | ||
config, | ||
logical_schema, | ||
metrics, | ||
|
@@ -1955,7 +1957,7 @@ mod tests { | |
use bytes::Bytes; | ||
use chrono::{TimeZone, Utc}; | ||
use datafusion::assert_batches_sorted_eq; | ||
use datafusion::datasource::physical_plan::ParquetExec; | ||
use datafusion::datasource::source::DataSourceExec; | ||
use datafusion::physical_plan::empty::EmptyExec; | ||
use datafusion::physical_plan::{visit_execution_plan, ExecutionPlanVisitor, PhysicalExpr}; | ||
use datafusion_expr::lit; | ||
|
@@ -2655,7 +2657,7 @@ mod tests { | |
.await | ||
.unwrap(); | ||
|
||
let mut visitor = ParquetPredicateVisitor::default(); | ||
let mut visitor = ParquetVisitor::default(); | ||
visit_execution_plan(&scan, &mut visitor).unwrap(); | ||
|
||
assert_eq!(visitor.predicate.unwrap().to_string(), "a@0 = s"); | ||
|
@@ -2690,7 +2692,7 @@ mod tests { | |
.await | ||
.unwrap(); | ||
|
||
let mut visitor = ParquetPredicateVisitor::default(); | ||
let mut visitor = ParquetVisitor::default(); | ||
visit_execution_plan(&scan, &mut visitor).unwrap(); | ||
|
||
assert!(visitor.predicate.is_none()); | ||
|
@@ -2719,42 +2721,46 @@ mod tests { | |
.await | ||
.unwrap(); | ||
|
||
let mut visitor = ParquetOptionsVisitor::default(); | ||
let mut visitor = ParquetVisitor::default(); | ||
visit_execution_plan(&scan, &mut visitor).unwrap(); | ||
|
||
assert_eq!(ctx.copied_table_options().parquet, visitor.options.unwrap()); | ||
} | ||
|
||
/// Extracts fields from the parquet scan | ||
#[derive(Default)] | ||
struct ParquetPredicateVisitor { | ||
struct ParquetVisitor { | ||
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 had to change the way the parquet scan information was found in the two visitors, and I combined them together at the same time as they were mostly boiler plate copy/paste |
||
predicate: Option<Arc<dyn PhysicalExpr>>, | ||
pruning_predicate: Option<Arc<PruningPredicate>>, | ||
options: Option<TableParquetOptions>, | ||
} | ||
|
||
impl ExecutionPlanVisitor for ParquetPredicateVisitor { | ||
impl ExecutionPlanVisitor for ParquetVisitor { | ||
type Error = DataFusionError; | ||
|
||
fn pre_visit(&mut self, plan: &dyn ExecutionPlan) -> Result<bool, Self::Error> { | ||
if let Some(parquet_exec) = plan.as_any().downcast_ref::<ParquetExec>() { | ||
self.predicate = parquet_exec.predicate().cloned(); | ||
self.pruning_predicate = parquet_exec.pruning_predicate().cloned(); | ||
} | ||
Ok(true) | ||
} | ||
} | ||
|
||
#[derive(Default)] | ||
struct ParquetOptionsVisitor { | ||
options: Option<TableParquetOptions>, | ||
} | ||
let Some(datasource_exec) = plan.as_any().downcast_ref::<DataSourceExec>() else { | ||
return Ok(true); | ||
}; | ||
|
||
impl ExecutionPlanVisitor for ParquetOptionsVisitor { | ||
type Error = DataFusionError; | ||
let Some(scan_config) = datasource_exec | ||
.data_source() | ||
.as_any() | ||
.downcast_ref::<FileScanConfig>() | ||
else { | ||
return Ok(true); | ||
}; | ||
|
||
fn pre_visit(&mut self, plan: &dyn ExecutionPlan) -> Result<bool, Self::Error> { | ||
if let Some(parquet_exec) = plan.as_any().downcast_ref::<ParquetExec>() { | ||
self.options = Some(parquet_exec.table_parquet_options().clone()) | ||
if let Some(parquet_source) = scan_config | ||
.file_source | ||
.as_any() | ||
.downcast_ref::<ParquetSource>() | ||
{ | ||
self.options = Some(parquet_source.table_parquet_options().clone()); | ||
self.predicate = parquet_source.predicate().cloned(); | ||
self.pruning_predicate = parquet_source.pruning_predicate().cloned(); | ||
} | ||
|
||
Ok(true) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
DataFusion 46 requires Rust 1.82
You can see CI fail without these changes
https://github.com/delta-io/delta-rs/actions/runs/13591787541/job/38000195037?pr=3261
I don't know what the MSRV policy in delta is so we probably can't merge this PR until it is ok to increase MSRV in delta