0lai0 commented on code in PR #5193:
URL: https://github.com/apache/datafusion-comet/pull/5193#discussion_r3699252707
##########
native/spark-expr/src/math_funcs/internal/make_decimal.rs:
##########
@@ -45,14 +47,41 @@ pub fn spark_make_decimal(
ColumnarValue::Array(a) => match a.data_type() {
DataType::Int64 => {
let arr = a.as_primitive::<Int64Type>();
- let mut result = Decimal128Builder::new();
- for v in arr.into_iter() {
- result.append_option(long_to_decimal(v, precision, scale,
fail_on_error)?)
- }
let result_type = DataType::Decimal128(precision, scale);
+ // The Int64 is already the unscaled Decimal128 value, so we
only reinterpret
+ // the bits (an Arrow Int64->Decimal cast would rescale the
value). Both arity
+ // helpers reuse the input null buffer and only invoke the
closure on valid rows.
+ let result: Decimal128Array = if fail_on_error {
Review Comment:
WIP
### `make_decimal` benchmark (8192 rows, target `Decimal128(18, 2)`)
Time per call (Criterion median). Lower is better.
| case | `main` (per-row loop) | `unary_opt` / `try_unary` | `unary` + scan
| speedup (main → best) |
|---|---|---|---|---|
| no nulls | 32.38 µs | 14.24 µs | TBD | TBD |
| sparse nulls (~10%) | 35.84 µs | 16.40 µs | TBD | TBD |
| dense nulls (~50%) | 35.44 µs | 10.41 µs | TBD | TBD |
| ansi no nulls | 31.81 µs | 21.61 µs | TBD | TBD |
| ansi sparse nulls (~10%) | 34.68 µs | 21.00 µs | TBD | TBD |
| ansi dense nulls (~50%) | 35.39 µs | 12.84 µs | TBD | TBD |
--
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]