Skip to content

Commit 173be79

Browse files
committed
style(array): include actual values in integer diagnostics
Signed-off-by: Connor Tsui <[email protected]>
1 parent 1b342f3 commit 173be79

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ArrayPlugin for DecimalPlugin {
4545
) -> VortexResult<Option<ArraySerialization>> {
4646
vortex_ensure!(
4747
array.is::<Decimal>(),
48-
"Decimal plugin cannot serialize {}",
48+
"Expected a decimal array, got {}",
4949
array.encoding_id()
5050
);
5151
let mut ctx = session.create_execution_ctx();

‎vortex-array/src/arrays/wide_integer/vtable.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ impl VTable for WideIntegerEncoding {
6868
) -> VortexResult<()> {
6969
vortex_ensure!(
7070
matches!(data.values_type, DecimalType::I128 | DecimalType::I256),
71-
"Expected wide integer storage"
71+
"Expected i128 or i256 storage, got {}",
72+
data.values_type
7273
);
7374
let alignment =
7475
match_each_decimal_value_type!(data.values_type, |T| { Alignment::of::<T>() });
7576
vortex_ensure!(
7677
data.values.is_aligned_to(alignment),
77-
"Integer storage is not aligned to {alignment:?}"
78+
"Expected integer storage alignment {alignment:?}, got {:?}",
79+
data.values.alignment()
7880
);
7981
vortex_ensure_eq!(slots.len(), 1);
8082
let expected_dtype = integer_dtype(data.values_type, dtype.nullability());
@@ -83,7 +85,9 @@ impl VTable for WideIntegerEncoding {
8385
data.values
8486
.len()
8587
.is_multiple_of(data.values_type.byte_width()),
86-
"Integer buffer must contain whole values"
88+
"Expected whole {} values, got {} bytes",
89+
data.values_type,
90+
data.values.len()
8791
);
8892
vortex_ensure_eq!(data.values.len() / data.values_type.byte_width(), len);
8993
if let Some(validity) = &slots[0] {

‎vortex-array/src/integer.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ pub(crate) fn from_buffer(buffer: IntegerBuffer) -> VortexResult<ArrayRef> {
179179

180180
/// Reads a non-null signed integer scalar without applying a decimal scale.
181181
pub(crate) fn scalar_value(scalar: &Scalar) -> VortexResult<DecimalValue> {
182-
vortex_ensure!(!scalar.is_null(), "Expected a non-null integer scalar");
182+
vortex_ensure!(
183+
!scalar.is_null(),
184+
"Expected a non-null integer scalar, got {scalar}"
185+
);
183186
if let Some(width) = WideInteger::width(scalar.dtype()) {
184187
return Ok(DecimalValue::I256(WideInteger::unpack_value(
185188
width,
@@ -262,7 +265,10 @@ pub(crate) fn scalar_from_integer(value: DecimalValue, dtype: &DType) -> VortexR
262265
/// Casts a signed integer scalar with checked width and nullability.
263266
pub(crate) fn cast_scalar(scalar: &Scalar, dtype: &DType) -> VortexResult<Scalar> {
264267
if scalar.is_null() {
265-
vortex_ensure!(dtype.is_nullable(), "Cannot cast null to {dtype}");
268+
vortex_ensure!(
269+
dtype.is_nullable(),
270+
"Expected a nullable integer dtype for a null scalar, got {dtype}"
271+
);
266272
return Ok(Scalar::null(dtype.clone()));
267273
}
268274

‎vortex-array/src/scalar_fn/fns/binary/compare/integer.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(super) fn compare_integer(
5858
) -> VortexResult<ArrayRef> {
5959
vortex_ensure!(
6060
lhs.dtype().eq_ignore_nullability(rhs.dtype()),
61-
"Cannot compare integer dtypes {} and {}",
61+
"Expected integer dtypes matching apart from nullability, got {} and {}",
6262
lhs.dtype(),
6363
rhs.dtype()
6464
);

0 commit comments

Comments
 (0)