Skip to content

Commit dddeb8c

Browse files
Upgrade to DataFusion 46 (#346)
* Upgrade to DataFusion 46 * fix * Use the same DF patch as spice * fix * Use 1.85 toolchain * Fix linking issue
1 parent fc6e1a5 commit dddeb8c

5 files changed

Lines changed: 46 additions & 35 deletions

File tree

Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ byte-unit = { version = "5.1.4", optional = true }
2020
bigdecimal = "0.4.5"
2121
byteorder = "1.5.0"
2222
chrono = "0.4"
23-
datafusion = "45"
24-
datafusion-expr = { version = "45", optional = true }
25-
datafusion-physical-expr = { version = "45", optional = true }
26-
datafusion-physical-plan = { version = "45", optional = true }
27-
datafusion-proto = { version = "45", optional = true }
23+
datafusion = "46"
24+
datafusion-expr = { version = "46", optional = true }
25+
datafusion-physical-expr = { version = "46", optional = true }
26+
datafusion-physical-plan = { version = "46", optional = true }
27+
datafusion-proto = { version = "46", optional = true }
2828
duckdb = { version = "1", features = [
2929
"bundled",
3030
"r2d2",
@@ -59,7 +59,7 @@ pem = { version = "3.0.4", optional = true }
5959
tokio-rusqlite = { version = "0.5.1", optional = true }
6060
tonic = { version = "0.12.2", optional = true }
6161
datafusion-federation = "0.1"
62-
datafusion-federation-sql = { git = "https://github.com/spiceai/datafusion-federation.git", rev = "1c814422cfbdeb7f7bd2399e3369656710413aa8" }
62+
datafusion-federation-sql = { git = "https://github.com/spiceai/datafusion-federation.git", rev = "a4c752a172904a0c214fc37ab2d62e907eb16c8f" }
6363
itertools = "0.13.0"
6464
dyn-clone = { version = "1.0.17", optional = true }
6565
geo-types = "0.7.13"
@@ -77,7 +77,7 @@ rstest = "0.22.0"
7777
geozero = { version = "0.13.0", features = ["with-wkb"] }
7878
tokio-stream = { version = "0.1.15", features = ["net"] }
7979
insta = { version = "1.40.0", features = ["filters"] }
80-
datafusion-physical-plan = { version = "45" }
80+
datafusion-physical-plan = { version = "46" }
8181
tempfile = "3.8.1"
8282

8383
[features]
@@ -103,11 +103,11 @@ sqlite-federation = ["sqlite"]
103103
postgres-federation = ["postgres"]
104104

105105
[patch.crates-io]
106-
datafusion-federation = { git = "https://github.com/spiceai/datafusion-federation.git", rev = "1c814422cfbdeb7f7bd2399e3369656710413aa8" } # spiceai-45
106+
datafusion-federation = { git = "https://github.com/spiceai/datafusion-federation.git", rev = "a4c752a172904a0c214fc37ab2d62e907eb16c8f" } # spiceai-46
107107
duckdb = { git = "https://github.com/spiceai/duckdb-rs.git", rev = "2e24b958e44ec7419290249e27a15f1a19703fff" } # spiceai-1.1.3-backported-arrow-54
108108

109-
datafusion = { git = "https://github.com/spiceai/datafusion.git", rev = "e0e423e9e29a711d076892865d51747b06429d1b"} # spiceai-45
110-
datafusion-expr = { git = "https://github.com/spiceai/datafusion.git", rev = "e0e423e9e29a711d076892865d51747b06429d1b"} # spiceai-45
111-
datafusion-physical-expr = { git = "https://github.com/spiceai/datafusion.git", rev = "e0e423e9e29a711d076892865d51747b06429d1b"} # spiceai-45
112-
datafusion-physical-plan = { git = "https://github.com/spiceai/datafusion.git", rev = "e0e423e9e29a711d076892865d51747b06429d1b"} # spiceai-45
113-
datafusion-proto = { git = "https://github.com/spiceai/datafusion.git", rev = "e0e423e9e29a711d076892865d51747b06429d1b"} # spiceai-45
109+
datafusion = { git = "https://github.com/spiceai/datafusion.git", rev = "987d143985657065c8fc4d3d347a2010fbf36fe4" } # spiceai-46
110+
datafusion-expr = { git = "https://github.com/spiceai/datafusion.git", rev = "987d143985657065c8fc4d3d347a2010fbf36fe4" } # spiceai-46
111+
datafusion-physical-expr = { git = "https://github.com/spiceai/datafusion.git", rev = "987d143985657065c8fc4d3d347a2010fbf36fe4" } # spiceai-46
112+
datafusion-physical-plan = { git = "https://github.com/spiceai/datafusion.git", rev = "987d143985657065c8fc4d3d347a2010fbf36fe4" } # spiceai-46
113+
datafusion-proto = { git = "https://github.com/spiceai/datafusion.git", rev = "987d143985657065c8fc4d3d347a2010fbf36fe4" } # spiceai-46

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "1.85.0"
3+
components = ["rustc", "cargo", "rustfmt", "clippy"]

tests/duckdb/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ use arrow::array::RecordBatch;
33
use arrow::datatypes::SchemaRef;
44
use datafusion::catalog::TableProviderFactory;
55
use datafusion::common::{Constraints, ToDFSchema};
6+
use datafusion::datasource::memory::MemorySourceConfig;
7+
use datafusion::datasource::source::DataSourceExec;
68
use datafusion::execution::context::SessionContext;
79
use datafusion::logical_expr::dml::InsertOp;
810
use datafusion::logical_expr::CreateExternalTable;
911
use datafusion::physical_plan::collect;
10-
use datafusion::physical_plan::memory::MemoryExec;
1112
use datafusion_federation::schema_cast::record_convert::try_cast_to;
1213
use datafusion_table_providers::duckdb::DuckDBTableProviderFactory;
1314
use rstest::rstest;
@@ -43,8 +44,10 @@ async fn arrow_duckdb_round_trip(
4344

4445
let ctx = SessionContext::new();
4546

46-
let mem_exec = MemoryExec::try_new(&[vec![arrow_record.clone()]], arrow_record.schema(), None)
47-
.expect("memory exec created");
47+
let mem_exec = DataSourceExec::new(Arc::new(
48+
MemorySourceConfig::try_new(&[vec![arrow_record.clone()]], arrow_record.schema(), None)
49+
.expect("memory source config created"),
50+
));
4851
let insert_plan = table_provider
4952
.insert_into(&ctx.state(), Arc::new(mem_exec), InsertOp::Append)
5053
.await
@@ -89,7 +92,8 @@ async fn arrow_duckdb_round_trip(
8992
#[case::struct_type(get_arrow_struct_record_batch(), "struct")]
9093
#[ignore] // DuckDB does not support Decimal256 / duckdb_arrow_scan failed to register view
9194
#[case::decimal(get_arrow_decimal_record_batch(), "decimal")]
92-
#[ignore] // Interval(DayTime) is not supported: / "Conversion Error: Could not convert Interval to Microsecond"
95+
#[ignore]
96+
// Interval(DayTime) is not supported: / "Conversion Error: Could not convert Interval to Microsecond"
9397
#[case::interval(get_arrow_interval_record_batch(), "interval")]
9498
#[ignore] // TimeUnit::Nanosecond is not correctly supported; written values are zeros
9599
#[case::duration(get_arrow_duration_record_batch(), "duration")]

tests/postgres/mod.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ use arrow::{
33
array::{Decimal128Array, RecordBatch},
44
datatypes::{DataType, Field, Schema, SchemaRef},
55
};
6-
use datafusion::common::{Constraints, ToDFSchema};
7-
use datafusion::execution::context::SessionContext;
86
use datafusion::logical_expr::CreateExternalTable;
97
use datafusion::physical_plan::collect;
10-
use datafusion::physical_plan::memory::MemoryExec;
118
use datafusion::{catalog::TableProviderFactory, logical_expr::dml::InsertOp};
9+
use datafusion::{
10+
common::{Constraints, ToDFSchema},
11+
datasource::source::DataSourceExec,
12+
};
13+
use datafusion::{datasource::memory::MemorySourceConfig, execution::context::SessionContext};
1214
use datafusion_federation::schema_cast::record_convert::try_cast_to;
1315
use datafusion_table_providers::{
1416
postgres::{DynPostgresConnectionPool, PostgresTableProviderFactory},
@@ -53,8 +55,10 @@ async fn arrow_postgres_round_trip(
5355
.expect("table provider created");
5456

5557
let ctx = SessionContext::new();
56-
let mem_exec = MemoryExec::try_new(&[vec![arrow_record.clone()]], arrow_record.schema(), None)
57-
.expect("memory exec created");
58+
let mem_exec = DataSourceExec::new(Arc::new(
59+
MemorySourceConfig::try_new(&[vec![arrow_record.clone()]], arrow_record.schema(), None)
60+
.expect("memory source config created"),
61+
));
5862
let insert_plan = table_provider
5963
.insert_into(&ctx.state(), Arc::new(mem_exec), InsertOp::Append)
6064
.await
@@ -279,11 +283,7 @@ async fn test_postgres_jsonb_type(port: usize) {
279283
('{"nested": {"key": "value"}}');
280284
"#;
281285

282-
let schema = Arc::new(Schema::new(vec![Field::new(
283-
"data",
284-
DataType::Utf8,
285-
true,
286-
)]));
286+
let schema = Arc::new(Schema::new(vec![Field::new("data", DataType::Utf8, true)]));
287287

288288
// Parse and re-serialize the JSON to ensure consistent ordering
289289
let expected_values = vec![
@@ -304,9 +304,7 @@ async fn test_postgres_jsonb_type(port: usize) {
304304

305305
let expected_record = RecordBatch::try_new(
306306
Arc::clone(&schema),
307-
vec![Arc::new(arrow::array::StringArray::from(
308-
expected_values,
309-
))],
307+
vec![Arc::new(arrow::array::StringArray::from(expected_values))],
310308
)
311309
.expect("Failed to create arrow record batch");
312310

tests/sqlite/mod.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ async fn arrow_sqlite_round_trip(
4040
// Create sqlite table from arrow records and insert arrow records
4141
let schema = Arc::clone(&arrow_record.schema());
4242
let create_table_stmts = CreateTableBuilder::new(schema, table_name).build_sqlite();
43-
let insert_table_stmt = InsertBuilder::new(&TableReference::from(table_name), vec![arrow_record.clone()])
44-
.build_sqlite(None)
45-
.expect("SQLite insert statement should be constructed");
43+
let insert_table_stmt = InsertBuilder::new(
44+
&TableReference::from(table_name),
45+
vec![arrow_record.clone()],
46+
)
47+
.build_sqlite(None)
48+
.expect("SQLite insert statement should be constructed");
4649

4750
// Test arrow -> Sqlite row coverage
4851
let _ = conn
@@ -59,8 +62,11 @@ async fn arrow_sqlite_round_trip(
5962

6063
// Perform the test twice: first, simulate a request without a known schema;
6164
// then, test result conversion with a known projected schema (matching the test RecordBatch).
62-
for projected_schema in vec![None, Some(arrow_record.schema())] {
63-
if ctx.table_exist(table_name).expect("should be able to check if table exists") {
65+
for projected_schema in [None, Some(arrow_record.schema())] {
66+
if ctx
67+
.table_exist(table_name)
68+
.expect("should be able to check if table exists")
69+
{
6470
ctx.deregister_table(table_name)
6571
.expect("Table should be deregistered");
6672
}

0 commit comments

Comments
 (0)