vortex_compute/cast/
decimal.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_dtype::DType;
5use vortex_error::VortexResult;
6use vortex_vector::Scalar;
7use vortex_vector::Vector;
8use vortex_vector::decimal::DecimalScalar;
9use vortex_vector::decimal::DecimalVector;
10use vortex_vector::match_each_dscalar;
11use vortex_vector::match_each_dvector;
12
13use crate::cast::Cast;
14
15impl Cast for DecimalVector {
16    type Output = Vector;
17
18    /// Dispatches to the underlying [`DVector<D>`](vortex_vector::decimal::DVector) implementation.
19    fn cast(&self, target_dtype: &DType) -> VortexResult<Vector> {
20        match_each_dvector!(self, |v| { Cast::cast(v, target_dtype) })
21    }
22}
23
24impl Cast for DecimalScalar {
25    type Output = Scalar;
26
27    /// Dispatches to the underlying [`DScalar<D>`](vortex_vector::decimal::DScalar) implementation.
28    fn cast(&self, target_dtype: &DType) -> VortexResult<Scalar> {
29        match_each_dscalar!(self, |s| { Cast::cast(s, target_dtype) })
30    }
31}