2010YOUY01 commented on code in PR #16831:
URL: https://github.com/apache/datafusion/pull/16831#discussion_r2233636830
##########
datafusion/optimizer/src/simplify_expressions/utils.rs:
##########
@@ -168,10 +133,17 @@ pub fn is_one(s: &Expr) -> bool {
Expr::Literal(ScalarValue::Float64(Some(v)), _) if *v == 1. => true,
Expr::Literal(ScalarValue::Decimal128(Some(v), _p, s), _) => {
*s >= 0
- && POWS_OF_TEN
Review Comment:
I have checked the lookup table approach is faster, perhaps it's better to
implement such table in Arrow instead.
```rust
fn bench_println(c: &mut Criterion) {
c.bench_function("pow-lookup-table", |b| {
b.iter(|| {
let precision = 30;
let max_scale = 25;
for s in 1..max_scale {
is_one(&lit(ScalarValue::Decimal128(
Some(i128::from(1)),
precision,
max_scale,
)));
}
})
});
// Decimal256 doesn't have a pre-computed power table
c.bench_function("pow-with-calculation", |b| {
b.iter(|| {
let precision = 30;
let max_scale = 25;
for s in 1..max_scale {
is_one(&lit(ScalarValue::Decimal256(
Some(i256::from(1)),
precision,
max_scale,
)));
}
})
});
}
```
```
pow-lookup-table time: [159.16 ns 161.86 ns 166.03 ns]
change: [-0.9307% +0.0846% +1.1886%] (p = 0.90 >
0.05)
No change in performance detected.
Found 10 outliers among 100 measurements (10.00%)
5 (5.00%) low mild
2 (2.00%) high mild
3 (3.00%) high severe
pow-with-calculation time: [673.14 ns 674.23 ns 675.36 ns]
change: [-0.3838% -0.1634% +0.0709%] (p = 0.18 >
0.05)
No change in performance detected.
Found 4 outliers among 100 measurements (4.00%)
1 (1.00%) low mild
3 (3.00%) high mild
```
--
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]