Repository navigation
Conversation
DecimalArray::scalar_at and the decimal min_max aggregate built their results with Scalar::decimal, which panics when a stored value does not fit the precision of the dtype. DecimalArray construction does not check its values and file reads trust the stored precision, so such a value could make a read panic. Add Scalar::try_decimal and use it in both places so they return an error instead. Signed-off-by: Vincent <1729065730@qq.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DecimalArray::scalar_atand the decimalmin_maxaggregate panicked when a stored value did not fit the precision of the dtype, because both built their results withScalar::decimal, which callsvortex_expecton the precision check. SinceDecimalArrayconstruction doesn't check its values and file reads trust the stored precision, a file holding such a value could make a read panic. With this change both calls return an error instead.This covers the two call sites named in the issue. The other
Scalar::decimalcallers on read and compute paths (sum,mean,cast,fill_null,between, the DecimalByteParts kernels) are left as they are here; they can move toScalar::try_decimalin follow-ups once each one is checked.Changes
Scalar::try_decimal, a fallible version ofScalar::decimal.Scalar::decimalnow calls it and still panics on a bad value, with the panic documented.DecimalArray::scalar_atusesScalar::try_decimaland returns the error.min_maxaggregate usesScalar::try_decimalfor the min and max and returns the error.test_scalar_at_value_outside_precision_errorsandtest_decimal_value_outside_precision_errorsuse the repro from the issue (100i8withdecimal(2, 0)), for one and two values. Both panicked ondevelopand now return an error.Tested with
cargo test -p vortex-array --lib(4426 passed),cargo clippy -p vortex-array --all-targets --all-features -- -D warnings, andcargo +nightly-2026-09-10 fmt -p vortex-array.AI assistance: I used an AI coding assistant to help write this change and the description; I reviewed the code and ran the tests above myself.