Skip to content

Commit 0dcf448

Browse files
committed
Define DecimalMetadata above DecimalPlugin
Signed-off-by: Connor Tsui <[email protected]>
1 parent 9856e12 commit 0dcf448

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

  • vortex-array/src/arrays/decimal/vtable/plugin

‎vortex-array/src/arrays/decimal/vtable/plugin/mod.rs‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,28 @@ use crate::arrays::decimal::DecimalDataParts;
3636
use crate::dtype::DecimalType;
3737
use crate::expr::stats::Precision;
3838

39+
/// The metadata of a `vortex.decimal` node.
40+
#[derive(prost::Message)]
41+
struct DecimalMetadata {
42+
/// The [`DecimalType`] discriminant of the stored width.
43+
///
44+
/// The width is recorded apart from the dtype, because a legacy node can store a width other
45+
/// than the canonical width of its precision.
46+
#[prost(int32, tag = "1")]
47+
values_type: i32,
48+
}
49+
50+
impl DecimalMetadata {
51+
fn get_values_type(&self) -> VortexResult<DecimalType> {
52+
DecimalType::try_from(self.values_type).map_err(|_| {
53+
vortex_err!(
54+
"DecimalMetadata values_type must be a known DecimalType, got {}",
55+
self.values_type
56+
)
57+
})
58+
}
59+
}
60+
3961
/// Writes a [`DecimalArray`] as a `vortex.decimal` node, and reads every such node as the
4062
/// canonical decimal array or a decimal [`Widen`].
4163
///
@@ -132,27 +154,5 @@ impl ArrayPlugin for DecimalPlugin {
132154
}
133155
}
134156

135-
/// The metadata of a `vortex.decimal` node.
136-
#[derive(prost::Message)]
137-
struct DecimalMetadata {
138-
/// The [`DecimalType`] discriminant of the stored width.
139-
///
140-
/// The width is recorded apart from the dtype, because a legacy node can store a width other
141-
/// than the canonical width of its precision.
142-
#[prost(int32, tag = "1")]
143-
values_type: i32,
144-
}
145-
146-
impl DecimalMetadata {
147-
fn get_values_type(&self) -> VortexResult<DecimalType> {
148-
DecimalType::try_from(self.values_type).map_err(|_| {
149-
vortex_err!(
150-
"DecimalMetadata values_type must be a known DecimalType, got {}",
151-
self.values_type
152-
)
153-
})
154-
}
155-
}
156-
157157
#[cfg(test)]
158158
mod tests;

0 commit comments

Comments
 (0)