Repository navigation
Guard the DecimalByteParts nullability cast rule - #10746
connortsui20 wants to merge 1 commit into
Conversation
The DecimalByteParts cast rule cast the most significant part for every target nullability, even when `Validity::trivially_cast_nullability` could not prove the cast safe. The rule now declines in that case, and a new `CastKernel` handles it at execution with `cast_nullability`. Casts that change the precision or the scale stay unsupported. The cast tests now use a session that registers the crate, so they reach the new kernel. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Merging this PR will degrade performance by 1.68%4 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Summary
The DecimalByteParts cast rule pushed every nullability cast into its most significant part (MSP), including casts to non-nullable that it could not prove safe. The cast-rule contract on
Validity::cast_nullabilitysays that aCastReducerule, which runs in the optimizer without execution, must decline whenValidity::trivially_cast_nullabilitycannot decide, and that aCastKernelhandles the cast at execution. No wrong result is visible today, because the null check still runs when the MSP cast executes, but the rule relied on every MSP encoding keeping that check.Changes
The rule now declines when
trivially_cast_nullabilityreturnsNone. A newCastKernelchecks the validity withcast_nullabilityand then rebuilds the array over the cast MSP, reusing the lower parts. Casts that change the precision or the scale stay unsupported.When the MSP has a validity array, a cast to non-nullable now stays a lazy
Castover the DecimalByteParts array until execution, instead of becoming a DecimalByteParts array in the optimizer. The MSP's own cast kernel checks the validity a second time, which for a primitive MSP is a lookup of the cached minimum.The cast tests now use a session that registers the crate, so they reach the new kernel. Seven other encodings push nullability casts the same way, tracked in #10750.
🤖 Generated with Claude Code