-
Notifications
You must be signed in to change notification settings - Fork 488
feat: upgrade to DataFusion 47.0.0 #3378
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
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 |
---|---|---|
|
@@ -358,7 +358,7 @@ impl ObjectStore for S3StorageBackend { | |
self.inner.get_opts(location, options).await | ||
} | ||
|
||
async fn get_range(&self, location: &Path, range: Range<usize>) -> ObjectStoreResult<Bytes> { | ||
async fn get_range(&self, location: &Path, range: Range<u64>) -> ObjectStoreResult<Bytes> { | ||
self.inner.get_range(location, range).await | ||
} | ||
|
||
|
@@ -370,15 +370,15 @@ impl ObjectStore for S3StorageBackend { | |
self.inner.delete(location).await | ||
} | ||
|
||
fn list(&self, prefix: Option<&Path>) -> BoxStream<'_, ObjectStoreResult<ObjectMeta>> { | ||
fn list(&self, prefix: Option<&Path>) -> BoxStream<'static, ObjectStoreResult<ObjectMeta>> { | ||
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. |
||
self.inner.list(prefix) | ||
} | ||
|
||
fn list_with_offset( | ||
&self, | ||
prefix: Option<&Path>, | ||
offset: &Path, | ||
) -> BoxStream<'_, ObjectStoreResult<ObjectMeta>> { | ||
) -> BoxStream<'static, ObjectStoreResult<ObjectMeta>> { | ||
self.inner.list_with_offset(prefix, offset) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,15 +50,6 @@ impl UserDefinedLogicalNodeCore for MetricObserver { | |
write!(f, "MetricObserver id={}", self.id) | ||
} | ||
|
||
fn from_template( | ||
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 an old api that was removed |
||
&self, | ||
exprs: &[datafusion_expr::Expr], | ||
inputs: &[datafusion_expr::LogicalPlan], | ||
) -> Self { | ||
self.with_exprs_and_inputs(exprs.to_vec(), inputs.to_vec()) | ||
.unwrap() | ||
} | ||
|
||
fn with_exprs_and_inputs( | ||
&self, | ||
_exprs: Vec<datafusion_expr::Expr>, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,10 +37,12 @@ use arrow_schema::{ | |
use arrow_select::concat::concat_batches; | ||
use async_trait::async_trait; | ||
use chrono::{DateTime, TimeZone, Utc}; | ||
use datafusion::catalog::memory::DataSourceExec; | ||
use datafusion::catalog::{Session, TableProviderFactory}; | ||
use datafusion::config::TableParquetOptions; | ||
use datafusion::datasource::physical_plan::{ | ||
wrap_partition_type_in_dict, wrap_partition_value_in_dict, FileScanConfig, ParquetSource, | ||
wrap_partition_type_in_dict, wrap_partition_value_in_dict, FileGroup, FileScanConfigBuilder, | ||
ParquetSource, | ||
}; | ||
use datafusion::datasource::{listing::PartitionedFile, MemTable, TableProvider, TableType}; | ||
use datafusion::execution::context::{SessionConfig, SessionContext, SessionState, TaskContext}; | ||
|
@@ -671,7 +673,7 @@ impl<'a> DeltaScanBuilder<'a> { | |
} | ||
}; | ||
|
||
let file_scan_config = FileScanConfig::new( | ||
let file_scan_config = FileScanConfigBuilder::new( | ||
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. |
||
self.log_store.object_store_url(), | ||
file_schema, | ||
Arc::new(file_source), | ||
|
@@ -682,15 +684,16 @@ impl<'a> DeltaScanBuilder<'a> { | |
// | ||
// See https://github.com/apache/datafusion/issues/11322 | ||
if file_groups.is_empty() { | ||
vec![vec![]] | ||
vec![FileGroup::from(vec![])] | ||
} else { | ||
file_groups.into_values().collect() | ||
file_groups.into_values().map(FileGroup::from).collect() | ||
}, | ||
) | ||
.with_statistics(stats) | ||
.with_projection(self.projection.cloned()) | ||
.with_limit(self.limit) | ||
.with_table_partition_cols(table_partition_cols); | ||
.with_table_partition_cols(table_partition_cols) | ||
.build(); | ||
|
||
let metrics = ExecutionPlanMetricsSet::new(); | ||
MetricBuilder::new(&metrics) | ||
|
@@ -702,7 +705,7 @@ impl<'a> DeltaScanBuilder<'a> { | |
|
||
Ok(DeltaScan { | ||
table_uri: ensure_table_uri(self.log_store.root_uri())?.as_str().into(), | ||
parquet_scan: file_scan_config.build(), | ||
parquet_scan: DataSourceExec::from_data_source(file_scan_config), | ||
config, | ||
logical_schema, | ||
metrics, | ||
|
@@ -1974,6 +1977,7 @@ mod tests { | |
use bytes::Bytes; | ||
use chrono::{TimeZone, Utc}; | ||
use datafusion::assert_batches_sorted_eq; | ||
use datafusion::datasource::physical_plan::FileScanConfig; | ||
use datafusion::datasource::source::DataSourceExec; | ||
use datafusion::physical_plan::empty::EmptyExec; | ||
use datafusion::physical_plan::{visit_execution_plan, ExecutionPlanVisitor, PhysicalExpr}; | ||
|
@@ -2731,10 +2735,6 @@ mod tests { | |
visit_execution_plan(&scan, &mut visitor).unwrap(); | ||
|
||
assert_eq!(visitor.predicate.unwrap().to_string(), "a@0 = s"); | ||
assert_eq!( | ||
visitor.pruning_predicate.unwrap().orig_expr().to_string(), | ||
"a@0 = s" | ||
); | ||
} | ||
|
||
#[tokio::test] | ||
|
@@ -2766,7 +2766,6 @@ mod tests { | |
visit_execution_plan(&scan, &mut visitor).unwrap(); | ||
|
||
assert!(visitor.predicate.is_none()); | ||
assert!(visitor.pruning_predicate.is_none()); | ||
} | ||
|
||
#[tokio::test] | ||
|
@@ -2801,7 +2800,6 @@ mod tests { | |
#[derive(Default)] | ||
struct ParquetVisitor { | ||
predicate: Option<Arc<dyn PhysicalExpr>>, | ||
pruning_predicate: Option<Arc<PruningPredicate>>, | ||
options: Option<TableParquetOptions>, | ||
} | ||
|
||
|
@@ -2828,7 +2826,6 @@ mod tests { | |
{ | ||
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) | ||
|
@@ -2974,8 +2971,8 @@ mod tests { | |
|
||
#[derive(Debug, PartialEq)] | ||
enum ObjectStoreOperation { | ||
GetRanges(LocationType, Vec<Range<usize>>), | ||
GetRange(LocationType, Range<usize>), | ||
GetRanges(LocationType, Vec<Range<u64>>), | ||
GetRange(LocationType, Range<u64>), | ||
GetOpts(LocationType), | ||
Get(LocationType), | ||
} | ||
|
@@ -3054,7 +3051,7 @@ mod tests { | |
async fn get_range( | ||
&self, | ||
location: &Path, | ||
range: Range<usize>, | ||
range: Range<u64>, | ||
) -> object_store::Result<Bytes> { | ||
self.operations | ||
.send(ObjectStoreOperation::GetRange( | ||
|
@@ -3068,7 +3065,7 @@ mod tests { | |
async fn get_ranges( | ||
&self, | ||
location: &Path, | ||
ranges: &[Range<usize>], | ||
ranges: &[Range<u64>], | ||
) -> object_store::Result<Vec<Bytes>> { | ||
self.operations | ||
.send(ObjectStoreOperation::GetRanges( | ||
|
@@ -3094,15 +3091,18 @@ mod tests { | |
self.inner.delete_stream(locations) | ||
} | ||
|
||
fn list(&self, prefix: Option<&Path>) -> BoxStream<'_, object_store::Result<ObjectMeta>> { | ||
fn list( | ||
&self, | ||
prefix: Option<&Path>, | ||
) -> BoxStream<'static, object_store::Result<ObjectMeta>> { | ||
self.inner.list(prefix) | ||
} | ||
|
||
fn list_with_offset( | ||
&self, | ||
prefix: Option<&Path>, | ||
offset: &Path, | ||
) -> BoxStream<'_, object_store::Result<ObjectMeta>> { | ||
) -> BoxStream<'static, object_store::Result<ObjectMeta>> { | ||
self.inner.list_with_offset(prefix, offset) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,6 @@ impl SchemaAdapter for DeltaSchemaAdapter { | |
Ok(( | ||
Arc::new(SchemaMapping { | ||
projected_schema: self.projected_table_schema.clone(), | ||
table_schema: self.table_schema.clone(), | ||
}), | ||
projection, | ||
)) | ||
|
@@ -69,29 +68,11 @@ impl SchemaAdapter for DeltaSchemaAdapter { | |
#[derive(Debug)] | ||
pub(crate) struct SchemaMapping { | ||
projected_schema: SchemaRef, | ||
table_schema: SchemaRef, | ||
} | ||
|
||
impl SchemaMapper for SchemaMapping { | ||
fn map_batch(&self, batch: RecordBatch) -> datafusion_common::Result<RecordBatch> { | ||
let record_batch = cast_record_batch(&batch, self.projected_schema.clone(), false, true)?; | ||
Ok(record_batch) | ||
} | ||
|
||
fn map_partial_batch(&self, batch: RecordBatch) -> datafusion_common::Result<RecordBatch> { | ||
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. Due to @adriangb simplifying the implementation in |
||
let partial_table_schema = Arc::new(Schema::new( | ||
batch | ||
.schema() | ||
.fields() | ||
.iter() | ||
.filter_map(|batch_field| { | ||
self.table_schema.field_with_name(batch_field.name()).ok() | ||
}) | ||
.cloned() | ||
.collect::<Vec<_>>(), | ||
)); | ||
|
||
let record_batch = cast_record_batch(&batch, partial_table_schema, false, true)?; | ||
Ok(record_batch) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,7 +300,8 @@ impl LogSegment { | |
let store = store.clone(); | ||
let read_schema = read_schema.clone(); | ||
async move { | ||
let mut reader = ParquetObjectReader::new(store, meta); | ||
let mut reader = | ||
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. |
||
ParquetObjectReader::new(store, meta.location).with_file_size(meta.size); | ||
let options = ArrowReaderOptions::new(); | ||
let reader_meta = ArrowReaderMetadata::load_async(&mut reader, options).await?; | ||
|
||
|
@@ -413,7 +414,7 @@ impl LogSegment { | |
let bytes = commit.get_bytes()?; | ||
let meta = ObjectMeta { | ||
location: path, | ||
size: bytes.len(), | ||
size: bytes.len() as u64, | ||
last_modified: Utc::now(), | ||
e_tag: None, | ||
version: None, | ||
|
@@ -777,7 +778,7 @@ pub(super) mod tests { | |
self.store.delete(location).await | ||
} | ||
|
||
fn list(&self, prefix: Option<&Path>) -> BoxStream<'_, Result<ObjectMeta>> { | ||
fn list(&self, prefix: Option<&Path>) -> BoxStream<'static, Result<ObjectMeta>> { | ||
std::thread::sleep(std::time::Duration::from_secs(1)); | ||
self.store.list(prefix) | ||
} | ||
|
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.
object_store
to0.12.0
apache/arrow-rs#7328 / Useu64
range instead ofusize
, for better wasm32 support apache/arrow-rs#6961