Skip to content

Commit 9e8d4f6

Browse files
authored
Merge pull request JanKaul#392 from splitgraph/datafusion-55-upgrade
chore: DataFusion 55 upgrade
2 parents ce2d3a1 + 3206fb1 commit 9e8d4f6

11 files changed

Lines changed: 688 additions & 344 deletions

File tree

Cargo.lock

Lines changed: 442 additions & 225 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ resolver = "2"
1515

1616
[workspace.dependencies]
1717
apache-avro = "0.21"
18-
arrow = "58"
19-
arrow-schema = "58"
18+
arrow = "59"
19+
arrow-schema = "59"
2020
async-trait = "0.1"
2121
bytes = "1"
2222
chrono = { version = "0.4", default-features = false, features = [
2323
"serde",
2424
"clock",
2525
] }
26-
datafusion = "54"
27-
datafusion-common = "54"
28-
datafusion-execution = "54"
29-
datafusion-expr = "54"
30-
datafusion-functions = { version = "54", features = ["crypto_expressions"] }
31-
datafusion-functions-aggregate = "54"
32-
datafusion-sql = "54"
26+
datafusion = "55"
27+
datafusion-common = "55"
28+
datafusion-execution = "55"
29+
datafusion-expr = "55"
30+
datafusion-functions = { version = "55", features = ["crypto_expressions"] }
31+
datafusion-functions-aggregate = "55"
32+
datafusion-sql = "55"
3333
derive-getters = "0.5.0"
3434
derive_builder = "0.20"
3535
futures = "0.3.31"
@@ -39,7 +39,7 @@ lazy_static = "1.5.0"
3939
lru = "0.18.0"
4040
object_store = { version = "0.13", features = ["aws", "gcp", "azure"] }
4141
murmur3 = { version = "0.5.2" }
42-
parquet = { version = "58", features = ["async", "object_store"] }
42+
parquet = { version = "59", features = ["async", "object_store"] }
4343
pin-project-lite = "0.2"
4444
regex = "1.11.1"
4545
rust_decimal = "1.42.0"

catalogs/iceberg-file-catalog/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,10 @@ impl CatalogList for FileCatalogList {
830830
pub mod tests {
831831
use datafusion::{
832832
arrow::array::{Float64Array, Int64Array},
833-
common::tree_node::{TransformedResult, TreeNode},
833+
common::{
834+
config::ConfigNonZeroUsize,
835+
tree_node::{TransformedResult, TreeNode},
836+
},
834837
execution::SessionStateBuilder,
835838
prelude::{SessionConfig, SessionContext},
836839
};
@@ -915,7 +918,8 @@ pub mod tests {
915918

916919
let mut config = SessionConfig::default();
917920

918-
config.options_mut().execution.minimum_parallel_output_files = 1;
921+
config.options_mut().execution.minimum_parallel_output_files =
922+
ConfigNonZeroUsize::try_new(1).unwrap();
919923
config
920924
.options_mut()
921925
.execution

datafusion_iceberg/src/materialized_view/delta_queries/fork_node.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ use std::{
1313
use async_trait::async_trait;
1414
use datafusion::{
1515
arrow::{array::RecordBatch, datatypes::SchemaRef},
16-
common::DFSchemaRef,
16+
catalog::Session,
17+
common::{tree_node::TreeNodeRecursion, DFSchemaRef},
1718
error::DataFusionError,
18-
execution::{RecordBatchStream, SendableRecordBatchStream, SessionState},
19+
execution::{RecordBatchStream, SendableRecordBatchStream},
20+
logical_expr::physical_planning_context::PhysicalPlanningContext,
1921
physical_plan::{
20-
stream::RecordBatchStreamAdapter, DisplayAs, ExecutionPlan, Partitioning, PlanProperties,
22+
stream::RecordBatchStreamAdapter, DisplayAs, ExecutionPlan, Partitioning, PhysicalExpr,
23+
PlanProperties,
2124
},
2225
physical_planner::{ExtensionPlanner, PhysicalPlanner},
2326
};
@@ -179,6 +182,13 @@ impl ExecutionPlan for PhysicalForkNode {
179182
vec![&self.input]
180183
}
181184

185+
fn apply_expressions(
186+
&self,
187+
_f: &mut dyn FnMut(&Arc<dyn PhysicalExpr>) -> Result<TreeNodeRecursion, DataFusionError>,
188+
) -> Result<TreeNodeRecursion, DataFusionError> {
189+
Ok(TreeNodeRecursion::Continue)
190+
}
191+
182192
fn with_new_children(
183193
self: Arc<Self>,
184194
mut children: Vec<Arc<dyn ExecutionPlan>>,
@@ -296,7 +306,8 @@ impl ExtensionPlanner for ForkNodePlanner {
296306
node: &dyn UserDefinedLogicalNode,
297307
logical_inputs: &[&LogicalPlan],
298308
physical_inputs: &[Arc<dyn ExecutionPlan>],
299-
_session_state: &SessionState,
309+
_session: &dyn Session,
310+
_planning_ctx: &PhysicalPlanningContext,
300311
) -> Result<Option<Arc<dyn ExecutionPlan>>, DataFusionError> {
301312
if let Some(fork_node) = node.as_any().downcast_ref::<ForkNode>() {
302313
assert_eq!(physical_inputs.len(), 1);

datafusion_iceberg/src/materialized_view/delta_queries/transform.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ use std::{
77
use datafusion::common::NullEquality;
88
use datafusion::{
99
catalog::TableProvider,
10-
common::{tree_node::Transformed, Column, DFSchema},
10+
common::{tree_node::Transformed, Column, DFSchema, TableReference},
1111
datasource::{empty::EmptyTable, DefaultTableSource},
1212
error::DataFusionError,
13-
sql::TableReference,
1413
};
1514
use datafusion_expr::{
1615
build_join_schema, expr::Alias, Aggregate, Expr, Filter, Join, JoinConstraint, JoinType,
17-
LogicalPlan, Projection, SubqueryAlias, TableScan, Union,
16+
LogicalPlan, Projection, SubqueryAlias, TableScanBuilder, Union,
1817
};
1918
use iceberg_rust::error::Error;
2019

@@ -38,13 +37,13 @@ pub(crate) fn delta_transform_down(
3837
) -> Result<Transformed<LogicalPlan>, DataFusionError> {
3938
let storage_table_reference = storage_table.0;
4039

41-
let storage_table_scan = Arc::new(LogicalPlan::TableScan(TableScan::try_new(
42-
storage_table_reference.clone(),
43-
Arc::new(DefaultTableSource::new(storage_table.1)),
44-
None,
45-
Vec::new(),
46-
None,
47-
)?));
40+
let storage_table_scan = Arc::new(LogicalPlan::TableScan(
41+
TableScanBuilder::new(
42+
storage_table_reference.clone(),
43+
Arc::new(DefaultTableSource::new(storage_table.1)),
44+
)
45+
.build()?,
46+
));
4847

4948
let storage_table_schema = storage_table_scan.schema().clone();
5049
match &plan {
@@ -549,9 +548,9 @@ mod tests {
549548
use std::{ops::Deref, sync::Arc};
550549

551550
use datafusion::common::tree_node::TreeNode;
551+
use datafusion::common::TableReference;
552552
use datafusion::datasource::empty::EmptyTable;
553553
use datafusion::prelude::SessionContext;
554-
use datafusion::sql::TableReference;
555554
use datafusion_expr::LogicalPlan;
556555
use iceberg_rust::catalog::Catalog;
557556
use iceberg_rust::object_store::ObjectStoreBuilder;

datafusion_iceberg/src/materialized_view/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
use std::{collections::HashMap, sync::Arc};
22

33
use datafusion::{
4-
arrow::error::ArrowError, catalog::TableProvider, common::tree_node::TreeNode,
5-
execution::SessionStateBuilder, prelude::SessionContext, sql::TableReference,
4+
arrow::error::ArrowError,
5+
catalog::TableProvider,
6+
common::{tree_node::TreeNode, TableReference},
7+
execution::SessionStateBuilder,
8+
prelude::SessionContext,
69
};
710
use datafusion_expr::LogicalPlan;
811
use delta_queries::{

datafusion_iceberg/src/planner.rs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@ use crate::{
1414
};
1515
use datafusion::{
1616
arrow::datatypes::{DataType, Schema as ArrowSchema},
17-
catalog::CatalogProvider,
18-
common::{tree_node::Transformed, SchemaReference},
17+
catalog::{CatalogProvider, Session},
18+
common::{tree_node::Transformed, SchemaReference, TableReference},
1919
error::DataFusionError,
20-
execution::context::{QueryPlanner, SessionState},
20+
execution::context::QueryPlanner,
2121
logical_expr::{
22-
CreateExternalTable, DdlStatement, Extension, InvariantLevel, LogicalPlan,
23-
UserDefinedLogicalNode,
22+
physical_planning_context::PhysicalPlanningContext, CreateExternalTable, DdlStatement,
23+
Extension, InvariantLevel, LogicalPlan, UserDefinedLogicalNode,
2424
},
2525
physical_plan::{empty::EmptyExec, ExecutionPlan},
2626
physical_planner::{DefaultPhysicalPlanner, ExtensionPlanner, PhysicalPlanner},
2727
scalar::ScalarValue,
28-
sql::TableReference,
2928
};
3029
use iceberg_rust::{
3130
catalog::{tabular::Tabular, CatalogList},
@@ -72,11 +71,9 @@ impl QueryPlanner for IcebergQueryPlanner {
7271
async fn create_physical_plan(
7372
&self,
7473
logical_plan: &LogicalPlan,
75-
session_state: &SessionState,
74+
session: &dyn Session,
7675
) -> Result<Arc<dyn ExecutionPlan>, DataFusionError> {
77-
self.0
78-
.create_physical_plan(logical_plan, session_state)
79-
.await
76+
self.0.create_physical_plan(logical_plan, session).await
8077
}
8178
}
8279

@@ -85,7 +82,7 @@ pub fn iceberg_transform(node: LogicalPlan) -> Result<Transformed<LogicalPlan>,
8582
LogicalPlan::Ddl(DdlStatement::CreateExternalTable(table)) => {
8683
if table.file_type.to_lowercase() == "iceberg" {
8784
Ok(Transformed::yes(LogicalPlan::Extension(Extension {
88-
node: Arc::new(CreateIcebergTable(table)),
85+
node: Arc::new(CreateIcebergTable(*table)),
8986
})))
9087
} else {
9188
Ok(Transformed::no(LogicalPlan::Ddl(
@@ -127,18 +124,19 @@ impl ExtensionPlanner for IcebergExtensionPlanner {
127124
node: &dyn UserDefinedLogicalNode,
128125
_logical_inputs: &[&LogicalPlan],
129126
_physical_inputs: &[Arc<dyn ExecutionPlan>],
130-
session_state: &SessionState,
127+
session: &dyn Session,
128+
_planning_ctx: &PhysicalPlanningContext,
131129
) -> Result<Option<Arc<dyn ExecutionPlan>>, DataFusionError> {
132130
if let Some(node) = node.as_any().downcast_ref::<CreateIcebergTable>() {
133-
plan_create_table(node, session_state).await
131+
plan_create_table(node, session).await
134132
} else if let Some(node) = node.as_any().downcast_ref::<CreateIcebergView>() {
135-
plan_create_view(node, session_state).await
133+
plan_create_view(node, session).await
136134
} else if let Some(node) = node.as_any().downcast_ref::<CreateIcebergNamespace>() {
137-
plan_create_namespace(node, session_state).await
135+
plan_create_namespace(node, session).await
138136
} else if let Some(node) = node.as_any().downcast_ref::<DropIcebergTable>() {
139-
plan_drop_table(node, session_state).await
137+
plan_drop_table(node, session).await
140138
} else if let Some(node) = node.as_any().downcast_ref::<DropIcebergNamespace>() {
141-
plan_drop_namespace(node, session_state).await
139+
plan_drop_namespace(node, session).await
142140
} else {
143141
return Ok(None);
144142
}
@@ -147,13 +145,13 @@ impl ExtensionPlanner for IcebergExtensionPlanner {
147145

148146
async fn plan_create_table(
149147
node: &CreateIcebergTable,
150-
session_state: &SessionState,
148+
session: &dyn Session,
151149
) -> Result<Option<Arc<dyn ExecutionPlan>>, DataFusionError> {
152150
let table_ref = &node.0.name.to_string();
153151

154152
let identifier = TableReference::parse_str(table_ref).resolve("datafusion", "public");
155153

156-
let catalog_list = session_state.catalog_list();
154+
let catalog_list = session.catalog_list();
157155
let catalog_name = &identifier.catalog;
158156
let namespace_name = &identifier.schema;
159157
let table_name: &str = &identifier.table;
@@ -206,9 +204,15 @@ async fn plan_create_table(
206204
.build()
207205
.map_err(|err| DataFusionError::External(Box::new(err)))?;
208206

207+
let [location] = node.0.locations.as_slice() else {
208+
return Err(DataFusionError::Plan(
209+
"Iceberg tables must be created with exactly one LOCATION.".to_owned(),
210+
));
211+
};
212+
209213
Table::builder()
210214
.with_name(table_name)
211-
.with_location(&node.0.location)
215+
.with_location(location)
212216
.with_schema(Schema::from_struct_type(schema, DEFAULT_SCHEMA_ID, None))
213217
.with_partition_spec(partition_spec)
214218
.with_properties(node.0.options.clone())
@@ -223,13 +227,13 @@ async fn plan_create_table(
223227

224228
async fn plan_create_view(
225229
node: &CreateIcebergView,
226-
session_state: &SessionState,
230+
session: &dyn Session,
227231
) -> Result<Option<Arc<dyn ExecutionPlan>>, DataFusionError> {
228232
let table_ref = &node.0.name.to_string();
229233

230234
let identifier = TableReference::parse_str(table_ref).resolve("datafusion", "public");
231235

232-
let catalog_list = session_state.catalog_list();
236+
let catalog_list = session.catalog_list();
233237
let catalog_name = &identifier.catalog;
234238
let namespace_name = &identifier.schema;
235239
let table_name: &str = &identifier.table;
@@ -347,7 +351,7 @@ async fn plan_create_view(
347351

348352
async fn plan_create_namespace(
349353
node: &CreateIcebergNamespace,
350-
session_state: &SessionState,
354+
session: &dyn Session,
351355
) -> Result<Option<Arc<dyn ExecutionPlan>>, DataFusionError> {
352356
let (catalog_name, namespace_name) =
353357
node.0
@@ -359,7 +363,7 @@ async fn plan_create_namespace(
359363
&node.0.schema_name
360364
)))?;
361365

362-
let catalog_list = session_state.catalog_list();
366+
let catalog_list = session.catalog_list();
363367
let datafusion_catalog = catalog_list
364368
.catalog(catalog_name)
365369
.ok_or(DataFusionError::Plan(format!(
@@ -393,13 +397,13 @@ async fn plan_create_namespace(
393397

394398
async fn plan_drop_table(
395399
node: &DropIcebergTable,
396-
session_state: &SessionState,
400+
session: &dyn Session,
397401
) -> Result<Option<Arc<dyn ExecutionPlan>>, DataFusionError> {
398402
let table_ref = &node.0.name.to_string();
399403

400404
let identifier = TableReference::parse_str(table_ref).resolve("datafusion", "public");
401405

402-
let catalog_list = session_state.catalog_list();
406+
let catalog_list = session.catalog_list();
403407
let catalog_name = &identifier.catalog;
404408
let namespace_name = &identifier.schema;
405409
let table_name: &str = &identifier.table;
@@ -431,14 +435,14 @@ async fn plan_drop_table(
431435

432436
async fn plan_drop_namespace(
433437
node: &DropIcebergNamespace,
434-
session_state: &SessionState,
438+
session: &dyn Session,
435439
) -> Result<Option<Arc<dyn ExecutionPlan>>, DataFusionError> {
436440
let (catalog_name, namespace_name) = match &node.0.name {
437441
SchemaReference::Bare { schema } => ("datafusion".to_owned(), schema.to_string()),
438442
SchemaReference::Full { schema, catalog } => (catalog.to_string(), schema.to_string()),
439443
};
440444

441-
let catalog_list = session_state.catalog_list();
445+
let catalog_list = session.catalog_list();
442446
let datafusion_catalog = catalog_list
443447
.catalog(&catalog_name)
444448
.ok_or(DataFusionError::Plan(format!(

0 commit comments

Comments
 (0)