You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/12 10:24:02 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #3782: Optimizer now simplifies multiplication, division, module arg is a literal Decimal zero or one

alamb commented on code in PR #3782:
URL: https://github.com/apache/arrow-datafusion/pull/3782#discussion_r993277694


##########
datafusion/optimizer/src/simplify_expressions.rs:
##########
@@ -137,6 +179,9 @@ fn is_one(s: &Expr) -> bool {
         | Expr::Literal(ScalarValue::UInt64(Some(1))) => true,
         Expr::Literal(ScalarValue::Float32(Some(v))) if *v == 1. => true,
         Expr::Literal(ScalarValue::Float64(Some(v))) if *v == 1. => true,
+        Expr::Literal(ScalarValue::Decimal128(Some(v), _p, _s)) => {
+            *_s < DECIMAL128_MAX_PRECISION && POWS_OF_TEN[*_s as usize] == *v

Review Comment:
   I think this code will run ~1 per query / expression, so I don't expect the any performance difference to be noticeable.
   
   For what it is worth, I think both approaches are reasonable. Thank you both for the discussion. 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org