2010YOUY01 opened a new issue, #6133:
URL: https://github.com/apache/arrow-datafusion/issues/6133

   ### Describe the bug
   
   I noticed this bug when reviewing panics for this issue 
https://github.com/apache/arrow-datafusion/issues/3316
   
https://github.com/apache/arrow-datafusion/blob/a38480951f40abce7ee2d5919251a1d1607f1dee/datafusion/physical-expr/src/math_expressions.rs#L215
   For `round(num, decimal_place)` function, when `decimal_place` overflow 
Int32 range, it will panic.
   
   ### To Reproduce
   
   ```sql
   -- max Int32 is 2147483647
   select round(3.14, 2147483648);
   ```
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   For a quick fix, the code can return an Execution Error instead of 
panicking. 
   
   However, it seems better to return a Planning Error during the Parsed Tree 
-> Logical Plan (aka binding) stage: (1) the `round(num, decimal_place)` 
implementation relies on the standard library, which only accepts `i32` for 
`decimal_place`. As a result, the function signature for decimal_place should 
be `int32`. (2) be more compatible with Postgres, it will return planning error 
for such query and the function signature for `decimal_place` is 32 bit int.
   
   Currently, all integers are parsed as i64 during planning. Implementing the 
suggested change might require more modifications. I would like to know if such 
changes are desired.
   


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

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

Reply via email to