Skip to content

Commit aa5c138

Browse files
fix[vortex-array]: correct convert to arrow from vortex (#5378)
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 9cf954f commit aa5c138

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

vortex-array/src/arrow/datum.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Datum {
4141
})
4242
}
4343

44-
pub fn with_target_datatype(
44+
pub fn try_new_with_target_datatype(
4545
array: &dyn Array,
4646
target_datatype: &DataType,
4747
) -> VortexResult<Self> {
@@ -57,6 +57,10 @@ impl Datum {
5757
})
5858
}
5959
}
60+
61+
pub fn data_type(&self) -> &DataType {
62+
self.array.data_type()
63+
}
6064
}
6165

6266
impl ArrowDatum for Datum {

vortex-array/src/compute/compare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ fn arrow_compare(
328328
BooleanArray::new(values, nulls)
329329
} else {
330330
let lhs = Datum::try_new(left)?;
331-
let rhs = Datum::try_new(right)?;
331+
let rhs = Datum::try_new_with_target_datatype(right, lhs.data_type())?;
332332

333333
match operator {
334334
Operator::Eq => cmp::eq(&lhs, &rhs)?,

vortex-array/src/compute/like.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ pub(crate) fn arrow_like(
192192
"Arrow Like: length mismatch for {}",
193193
array.encoding_id()
194194
);
195+
196+
// convert the pattern to the preferred array datatype
195197
let lhs = Datum::try_new(array)?;
196-
let rhs = Datum::try_new(pattern)?;
198+
let rhs = Datum::try_new_with_target_datatype(pattern, lhs.data_type())?;
197199

198200
let result = match (options.negated, options.case_insensitive) {
199201
(false, false) => arrow_string::like::like(&lhs, &rhs)?,

vortex-array/src/compute/numeric.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn arrow_numeric(
254254
let len = lhs.len();
255255

256256
let left = Datum::try_new(lhs)?;
257-
let right = Datum::try_new(rhs)?;
257+
let right = Datum::try_new_with_target_datatype(rhs, left.data_type())?;
258258

259259
let array = match operator {
260260
NumericOperator::Add => arrow_arith::numeric::add(&left, &right)?,

0 commit comments

Comments
 (0)