From fc541af52638f88f579c5d53a97f2605799f305d Mon Sep 17 00:00:00 2001 From: Clemens Winter Date: Tue, 30 Jul 2024 20:03:12 -0700 Subject: [PATCH] Actually fix multiplication/division with null columns --- src/engine/execution/batch_merging.rs | 12 +++++++----- src/engine/operators/type_conversion.rs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/engine/execution/batch_merging.rs b/src/engine/execution/batch_merging.rs index 11d9daaa..cfb57efd 100644 --- a/src/engine/execution/batch_merging.rs +++ b/src/engine/execution/batch_merging.rs @@ -173,11 +173,13 @@ pub fn combine<'a>( for (&(ileft, aggregator), &(iright, _)) in batch1.aggregations.iter().zip(batch2.aggregations.iter()) { - let left = left[ileft]; - let right = right[iright]; - let (left, right) = unify_types(&mut qp, left, right); - let left = null_to_val(&mut qp, left); - let right = null_to_val(&mut qp, right); + let mut left = left[ileft]; + let mut right = right[iright]; + if (left.tag, right.tag) == (EncodingType::I64, EncodingType::F64) { + left = qp.cast(left, EncodingType::F64); + } else if (left.tag, right.tag) == (EncodingType::F64, EncodingType::I64) { + right = qp.cast(right, EncodingType::F64); + } let aggregated = qp.merge_aggregate(ops, left, right, aggregator); aggregates.push((aggregated.any(), aggregator)); } diff --git a/src/engine/operators/type_conversion.rs b/src/engine/operators/type_conversion.rs index 43bcb77b..a4315422 100644 --- a/src/engine/operators/type_conversion.rs +++ b/src/engine/operators/type_conversion.rs @@ -99,7 +99,7 @@ impl Cast for u16 { fn cast(self) -> OrderedFloat { OrderedFloat::fro impl Cast for u32 { fn cast(self) -> OrderedFloat { OrderedFloat::from(self as f64) } } -impl Cast for i64 { fn cast(self) -> OrderedFloat { OrderedFloat::from(self as f64) } } +impl Cast for i64 { fn cast(self) -> OrderedFloat { if self == I64_NULL { F64_NULL } else { OrderedFloat::from(self as f64) } } } impl<'a> Cast> for u8 { fn cast(self) -> Val<'a> { Val::Integer(self as i64) } }