Skip to content

Conversation

@fvaleye
Copy link

@fvaleye fvaleye commented Oct 30, 2025

Description

A minor refactoring to handle type conversion, improving Decimalperformance.

  • Introduced a small new abstraction, IntoResult, to normalize cast::From<...>::cast(...) return types. This eliminates the need to special-case when' cast' returns a primitive versus a Result<T, _>. Now, a single .into_result(...) call can be used everywhere to convert to Result<T, FromSqlError>.

  • Updated Decimal handling to match DuckDB rounding semantics (round half away from zero). Uses rust_decimal to round to an integral mantissa before casting, avoiding string parsing and explicitly encoding the correct semantics.

  • Modified Text conversion so that the string value is captured once when an error occurs.

- introduce IntoResult to eliminate is_ok() + unwrap patterns
- unify integer conversions using a single-line cast

Signed-off-by: Florian Valeye <[email protected]>
…to avoid string allocation

Following PostgreSQL, the round_dp_with_strategy(..., MidpointAwayFromZero) gives identical semantics to DuckDB’s Decimal to Integer cast.

Signed-off-by: Florian Valeye <[email protected]>
@fvaleye fvaleye force-pushed the refactor/from-sql-into-result branch from e6f5495 to 56dd28c Compare October 30, 2025 15:54
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.

1 participant