Skip to content

Commit e0c00d5

Browse files
authored
Canonical dict execute handles edge cases in Decimal/Bool logic (#10098)
There are edge cases where the downcast would fail Signed-off-by: Robert Kruszewski <[email protected]>
1 parent b5fa20f commit e0c00d5

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

‎vortex-array/src/arrays/dict/execute.rs‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pub(crate) fn take_canonical(
4949
Ok(match values {
5050
CanonicalView::Null(a) => Canonical::Null(take_null(a, codes)),
5151
CanonicalView::Bool(a) => Canonical::Bool(take_bool(a, codes, ctx)?),
52-
CanonicalView::Primitive(a) => Canonical::Primitive(take_primitive(a, codes, ctx)),
53-
CanonicalView::Decimal(a) => Canonical::Decimal(take_decimal(a, codes, ctx)),
52+
CanonicalView::Primitive(a) => Canonical::Primitive(take_primitive(a, codes, ctx)?),
53+
CanonicalView::Decimal(a) => Canonical::Decimal(take_decimal(a, codes, ctx)?),
5454
CanonicalView::VarBinView(a) => Canonical::VarBinView(take_varbinview(a, codes, ctx)),
5555
CanonicalView::List(a) => Canonical::List(take_listview(a, codes, ctx)),
5656
CanonicalView::Map(a) => Canonical::Map(take_map(a, codes, ctx)),
@@ -83,36 +83,31 @@ fn take_bool(
8383
ctx: &mut ExecutionCtx,
8484
) -> VortexResult<BoolArray> {
8585
let codes_ref = codes.array();
86-
Ok(<Bool as TakeExecute>::take(array, codes_ref, ctx)?
86+
<Bool as TakeExecute>::take(array, codes_ref, ctx)?
8787
.vortex_expect("take bool should not return None")
88-
.as_::<Bool>()
89-
.into_owned())
88+
.execute::<BoolArray>(ctx)
9089
}
9190

9291
fn take_primitive(
9392
array: ArrayView<'_, Primitive>,
9493
codes: ArrayView<'_, Primitive>,
9594
ctx: &mut ExecutionCtx,
96-
) -> PrimitiveArray {
95+
) -> VortexResult<PrimitiveArray> {
9796
let codes_ref = codes.array();
98-
<Primitive as TakeExecute>::take(array, codes_ref, ctx)
99-
.vortex_expect("take primitive array")
97+
<Primitive as TakeExecute>::take(array, codes_ref, ctx)?
10098
.vortex_expect("take primitive should not return None")
10199
.execute::<PrimitiveArray>(ctx)
102-
.vortex_expect("canonicalize taken primitive array")
103100
}
104101

105102
fn take_decimal(
106103
array: ArrayView<'_, Decimal>,
107104
codes: ArrayView<'_, Primitive>,
108105
ctx: &mut ExecutionCtx,
109-
) -> DecimalArray {
106+
) -> VortexResult<DecimalArray> {
110107
let codes_ref = codes.array();
111-
<Decimal as TakeExecute>::take(array, codes_ref, ctx)
112-
.vortex_expect("take decimal array")
108+
<Decimal as TakeExecute>::take(array, codes_ref, ctx)?
113109
.vortex_expect("take decimal should not return None")
114-
.as_::<Decimal>()
115-
.into_owned()
110+
.execute::<DecimalArray>(ctx)
116111
}
117112

118113
fn take_varbinview(

0 commit comments

Comments
 (0)