Skip to content

Reject decimal values that violate their dtype in DecimalScalar::try_new - #12362

Open
seragAhmed wants to merge 1 commit into
vortex-data:developfrom
seragAhmed:fix/11957-decimal-scalar-validate
Open

seragAhmed wants to merge 1 commit into
vortex-data:developfrom
seragAhmed:fix/11957-decimal-scalar-validate

Conversation

@seragAhmed

Copy link
Copy Markdown
Contributor

DecimalScalar::try_new accepted values that did not fit the declared precision and nulls for a non-nullable dtype (and panicked on non-decimal values), while From<DecimalScalar> for Scalar relies on the view being valid when it calls Scalar::new_unchecked. Running Scalar::validate in try_new rejects these at construction; Scalar::as_decimal is unaffected because a Scalar is already valid.

AI assistance: this change was written with Claude Code and reviewed by me.

DecimalScalar::try_new accepted values that did not fit the precision,
nulls for a non-nullable dtype, and panicked on non-decimal values. The
infallible From<DecimalScalar> for Scalar then built the Scalar with
new_unchecked, assuming the view was valid. try_new now runs
Scalar::validate, so invalid inputs are rejected at construction.

Closes vortex-data#11957

Signed-off-by: Serag Ahmed <serag.science2011@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate DecimalScalar values against their dtype invariants

1 participant