Skip to content

Commit f1009bd

Browse files
committed
fix
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 3e6ba8b commit f1009bd

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

vortex-array/src/scalar/convert/from_scalar.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ impl TryFrom<&Scalar> for bool {
113113
type Error = VortexError;
114114

115115
fn try_from(value: &Scalar) -> VortexResult<Self> {
116-
<Option<bool>>::try_from(value)?
116+
value
117+
.as_bool_opt()
118+
.ok_or_else(|| vortex_err!("Expected bool scalar, found {}", value.dtype()))?
119+
.value()
117120
.ok_or_else(|| vortex_err!("Can't extract present value from null scalar"))
118121
}
119122
}

vortex-array/src/vtable/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,14 @@ pub fn child_to_validity(child: &Option<ArrayRef>, nullability: Nullability) ->
255255
Some(arr) => {
256256
// Detect constant bool arrays created by validity_to_child.
257257
// Use direct ScalarValue matching to avoid expensive scalar conversion.
258-
if let Some(c) = arr.as_opt::<Constant>() {
259-
if let Some(ScalarValue::Bool(val)) = c.scalar().value() {
258+
if let Some(c) = arr.as_opt::<Constant>()
259+
&& let Some(ScalarValue::Bool(val)) = c.scalar().value() {
260260
return if *val {
261261
Validity::AllValid
262262
} else {
263263
Validity::AllInvalid
264264
};
265265
}
266-
}
267266
Validity::Array(arr.clone())
268267
}
269268
None => Validity::from(nullability),

0 commit comments

Comments
 (0)