From 2a5e3c71d617e3238000462020db8f26711767e6 Mon Sep 17 00:00:00 2001 From: Mikhail Kot Date: Tue, 8 Sep 2026 14:53:40 +0100 Subject: [PATCH 1/2] duckdb: don't optimize_recursive() before exporting chunks Signed-off-by: Mikhail Kot --- vortex-duckdb/src/table_function.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/vortex-duckdb/src/table_function.rs b/vortex-duckdb/src/table_function.rs index 6d573300b71..069551e70e2 100644 --- a/vortex-duckdb/src/table_function.rs +++ b/vortex-duckdb/src/table_function.rs @@ -19,11 +19,8 @@ use vortex::aggregate_fn::DynAccumulator; use vortex::array::ArrayRef; use vortex::array::Canonical; use vortex::array::ExecutionCtx; -use vortex::array::arrays::ScalarFn; use vortex::array::arrays::Struct; use vortex::array::arrays::StructArray; -use vortex::array::arrays::scalar_fn::ScalarFnArrayExt; -use vortex::array::optimizer::ArrayOptimizer; use vortex::dtype::DType; use vortex::dtype::PType; use vortex::error::VortexExpect; @@ -36,7 +33,6 @@ use vortex::metrics::tracing::get_global_labels; use vortex::scalar::Scalar; use vortex::scalar_fn::fns::binary::Binary; use vortex::scalar_fn::fns::operators::Operator; -use vortex::scalar_fn::fns::pack::Pack; use vortex_utils::aliases::hash_map::HashMap; use crate::convert::PushedAggregate; @@ -378,20 +374,14 @@ pub(crate) fn optimize_and_bind(expr: Expression, dtype: &DType) -> VortexResult } pub(crate) fn convert_result(array: ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult { - let array_result = array.optimize_recursive(ctx.session())?; - Ok(if let Some(array) = array_result.as_opt::() { + // By the time we got here, array is fully optimized, don't call + // optimize_recursive or similar functions here. + Ok(if let Some(array) = array.as_opt::() { array.into_owned() - } else if let Some(array) = array_result.as_opt::() - && let Some(pack_options) = array.scalar_fn().as_opt::() - { - StructArray::new( - pack_options.names.clone(), - array.children(), - array.len(), - pack_options.nullability.into(), - ) } else { - array_result.execute::(ctx)?.into_struct() + // In very rare cases we may get a DType::Struct which is not a Struct + // array + array.execute::(ctx)?.into_struct() }) } From 0186b468e052cebd5874a754f389d93ce32ba32c Mon Sep 17 00:00:00 2001 From: Mikhail Kot Date: Thu, 10 Sep 2026 11:42:23 +0100 Subject: [PATCH 2/2] fix Signed-off-by: Mikhail Kot --- vortex-duckdb/src/table_function.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/vortex-duckdb/src/table_function.rs b/vortex-duckdb/src/table_function.rs index 069551e70e2..88aa9f9bd1c 100644 --- a/vortex-duckdb/src/table_function.rs +++ b/vortex-duckdb/src/table_function.rs @@ -379,8 +379,6 @@ pub(crate) fn convert_result(array: ArrayRef, ctx: &mut ExecutionCtx) -> VortexR Ok(if let Some(array) = array.as_opt::() { array.into_owned() } else { - // In very rare cases we may get a DType::Struct which is not a Struct - // array array.execute::(ctx)?.into_struct() }) }