Spaarsh commented on issue #15174:
URL: https://github.com/apache/datafusion/issues/15174#issuecomment-2717553058

   From what I've gathered after investigating this, I think the problem lies 
in how the `sql_expr_to_logical_expr` is making a plan for evaluating such an 
expression.
   
[sql_expr_to_logical_expr](https://github.com/apache/datafusion/blob/efb75f3fe34b0de51ff7aed1959451202e7733a4/datafusion/sql/src/expr/mod.rs#L66)
 makes a plan:
   1. `sql_expr_to_logical_expr`
   2. Eventually `binary_op` called
   3. `binary` called
   4. `binary_numeric_coercion` called
   5. `decimal_coercion` called
   6. `get_wider_decimal` called
   7. decimals converted to same scale for comparison
   
   For the first case, the multiplication is done first and then the above flow 
is done. For the second query, the plan is made first, so the plan converts the 
decimals and then proceeds to multiply the left one which leads to a scale 
change in the left decimal. Hence the error.
   
   I've deduced this from dry running this. I'll drop a comment once I go 
through the stack made by `sql_expr_to_logical_expr`.


-- 
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-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to