From c9e743913d07e251068a3548c3b97e381583c40a Mon Sep 17 00:00:00 2001 From: Joe Isaacs Date: Fri, 16 Oct 2026 12:35:36 +0100 Subject: [PATCH] perf(datafusion): avoid Arrow session lookup for ordinary scalars Fetch the Arrow session only in temporal conversions that need its type mapping. Signed-off-by: Joe Isaacs --- vortex-datafusion/src/convert/scalars.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vortex-datafusion/src/convert/scalars.rs b/vortex-datafusion/src/convert/scalars.rs index 344c77f2cae..f1a7d2209c4 100644 --- a/vortex-datafusion/src/convert/scalars.rs +++ b/vortex-datafusion/src/convert/scalars.rs @@ -188,7 +188,6 @@ impl TryToDataFusion for Scalar { /// Converts a DataFusion [`ScalarValue`] to a Vortex [`Scalar`], resolving Arrow types through /// `session`'s [`ArrowSession`](vortex_arrow::ArrowSession). pub fn scalar_from_df(value: &ScalarValue, session: &VortexSession) -> VortexResult { - let arrow = session.arrow(); Ok(match value { ScalarValue::Null => Scalar::null(DType::Null), ScalarValue::Boolean(b) => b @@ -241,7 +240,8 @@ pub fn scalar_from_df(value: &ScalarValue, session: &VortexSession) -> VortexRes ScalarValue::Date32(v) | ScalarValue::Time32Second(v) | ScalarValue::Time32Millisecond(v) => { - let dtype = arrow + let dtype = session + .arrow() .from_arrow_datatype(&value.data_type(), Nullability::Nullable) .vortex_expect("arrow data type to dtype"); Scalar::try_new(dtype, v.map(vortex::scalar::ScalarValue::from)) @@ -254,7 +254,8 @@ pub fn scalar_from_df(value: &ScalarValue, session: &VortexSession) -> VortexRes | ScalarValue::TimestampMillisecond(v, _) | ScalarValue::TimestampMicrosecond(v, _) | ScalarValue::TimestampNanosecond(v, _) => { - let dtype = arrow + let dtype = session + .arrow() .from_arrow_datatype(&value.data_type(), Nullability::Nullable) .vortex_expect("arrow data type to dtype"); Scalar::try_new(dtype, v.map(vortex::scalar::ScalarValue::from))