jeffw13 opened a new pull request, #7802: URL: https://github.com/apache/datafusion-comet/pull/7802
## Which issue does this PR close? Part of #5128. ## Rationale for this change The existing exactness checks already guarantee that the coefficient fits in a smaller integer. ## What changes are included in this PR? Cast through `i64` for double and `i32` for float inside those bounds. Scale-2 casts with in-range coefficients were 3.44× and 3.82× faster, respectively. Rounding and the wide-value fallback are unchanged. ## How are these changes tested? Added both signs at and around 2²⁴ and 2⁵³ to the bitwise rounding test. Extended the cast benchmark to cover nonzero scale. The native expression tests passed. Spark’s `CometNativeCastSuite` reported 207 passed, 1 canceled and 8 ignored. <details> <summary>Criterion results</summary> `cargo bench --bench cast_numeric`, main (`07caef5f`) vs this change, AMD EPYC Genoa, x86-64-v3. Rust 1.99.1. Median of four alternating runs per version. | Case | main (µs) | PR (µs) | Speedup | |---|---:|---:|---:| | `cast_decimal_scale_zero/decimal12_to_f32` | 43.06 | 41.92 | 1.03× | | `cast_decimal_scale_zero/decimal12_to_f32_nulls` | 42.35 | 43.34 | 0.98× | | `cast_decimal_scale_zero/decimal18_to_f64` | 42.39 | 43.84 | 0.97× | | `cast_decimal_scale_zero/decimal18_to_f64_nulls` | 43.58 | 42.68 | 1.02× | | `cast_decimal_scale_zero/decimal38_to_f64` | 45.23 | 45.48 | 0.99× | | `cast_decimal_scale_zero/decimal38_to_f64_nulls` | 43.31 | 44.47 | 0.97× | | `cast_decimal_scaled/f32/exact` | 56.20 | 14.70 | 3.82× | | `cast_decimal_scaled/f32/exact_dense_nulls` | 57.86 | 13.84 | 4.18× | | `cast_decimal_scaled/f32/exact_nulls` | 57.98 | 13.73 | 4.22× | | `cast_decimal_scaled/f32/mixed` | 423.58 | 383.08 | 1.11× | | `cast_decimal_scaled/f32/wide` | 1128.99 | 1138.21 | 0.99× | | `cast_decimal_scaled/f64/exact` | 55.88 | 16.23 | 3.44× | | `cast_decimal_scaled/f64/exact_dense_nulls` | 58.17 | 15.94 | 3.65× | | `cast_decimal_scaled/f64/exact_nulls` | 55.85 | 15.85 | 3.52× | | `cast_decimal_scaled/f64/mixed` | 451.52 | 426.06 | 1.06× | | `cast_decimal_scaled/f64/wide` | 1140.18 | 1125.64 | 1.01× | </details> *Drafted with OpenAI Codex.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
