Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ duckdb = [
"dep:arrow-schema",
"dep:byte-unit",
"dep:datafusion-physical-expr",
"federation",
]
duckdb-federation = ["duckdb", "federation"]
federation = ["dep:datafusion-federation"]
Expand Down
7 changes: 4 additions & 3 deletions core/src/sql/db_connection_pool/dbconnection/duckdbconn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use snafu::{prelude::*, ResultExt};
use tokio::sync::mpsc::Sender;

use crate::sql::db_connection_pool::runtime::run_sync_with_tokio;
use crate::util::arrow::cast_batch_to_schema;
use crate::util::schema::SchemaValidator;
use crate::UnsupportedTypeAction;

Expand Down Expand Up @@ -507,9 +506,11 @@ impl SyncDbConnection<r2d2::PooledConnection<DuckdbConnectionManager>, DuckDBPar
let output_stream = stream! {
while let Some(batch) = batch_rx.recv().await {
if let Some(ref target_schema) = projected_schema {
match cast_batch_to_schema(&batch, target_schema) {
match datafusion_federation::schema_cast::record_convert::try_cast_to(batch, Arc::clone(target_schema)) {
Ok(casted) => yield Ok(casted),
Err(e) => yield Err(e),
Err(e) => yield Err(DataFusionError::Execution(format!(
"Failed to cast DuckDB result batch to projected schema: {e}"
))),
}
} else {
yield Ok(batch);
Expand Down
125 changes: 0 additions & 125 deletions core/src/util/arrow.rs

This file was deleted.

1 change: 0 additions & 1 deletion core/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::collections::HashMap;

use crate::UnsupportedTypeAction;

pub mod arrow;
pub mod column_reference;
pub mod constraints;
pub mod count_exec;
Expand Down
6 changes: 2 additions & 4 deletions core/tests/duckdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ use datafusion::execution::context::SessionContext;
use datafusion::logical_expr::dml::InsertOp;
use datafusion::logical_expr::CreateExternalTable;
use datafusion::physical_plan::collect;
use datafusion_federation::schema_cast::record_convert::try_cast_to;
use datafusion_table_providers::duckdb::DuckDBTableProviderFactory;
use rstest::rstest;
use std::collections::HashMap;
use std::sync::Arc;

async fn arrow_duckdb_round_trip(
arrow_record: RecordBatch,
source_schema: SchemaRef,
_source_schema: SchemaRef,
table_name: &str,
) {
let factory = DuckDBTableProviderFactory::new(duckdb::AccessMode::ReadWrite);
Expand Down Expand Up @@ -68,7 +67,6 @@ async fn arrow_duckdb_round_trip(
.expect("DataFrame should be created from query");

let record_batch = df.collect().await.expect("RecordBatch should be collected");
let casted_record = try_cast_to(record_batch[0].clone(), source_schema).unwrap();
Comment thread
sgrebnov marked this conversation as resolved.

tracing::debug!("Original Arrow Record Batch: {:?}", arrow_record.columns());
tracing::debug!(
Expand All @@ -80,7 +78,7 @@ async fn arrow_duckdb_round_trip(
assert_eq!(record_batch.len(), 1);
assert_eq!(record_batch[0].num_rows(), arrow_record.num_rows());
assert_eq!(record_batch[0].num_columns(), arrow_record.num_columns());
assert_eq!(casted_record, arrow_record);
assert_eq!(record_batch[0], arrow_record);
}

#[rstest]
Expand Down
Loading