mmooyyii commented on code in PR #17113:
URL: https://github.com/apache/datafusion/pull/17113#discussion_r2265546105


##########
datafusion/functions/src/math/round.rs:
##########
@@ -64,6 +67,10 @@ impl RoundFunc {
                     Exact(vec![Float32, Int64]),
                     Exact(vec![Float64]),
                     Exact(vec![Float32]),
+                    Exact(vec![Decimal128(38, 10), Int64]),

Review Comment:
   try round(number::decimal(38,10)); it will cast to float64;
   I think use Signature::user_defined is better;
   ```
   fn coerce_types(&self, arg_types: &[DataType]) -> Result<Vec<DataType>> {
           if arg_types.len() != 1 && arg_types.len() != 2 {}
           if arg_types.len() == 1 {
               match arg_types[0].clone() {
                   Decimal128(p, s) => Ok(vec![Decimal128(p, s)]),
                   Decimal256(p, s) => Ok(vec![Decimal256(p, s)]),
                   Float32 => Ok(vec![Float32]),
                   _ => Ok(vec![Float64]),
               }
           } else if arg_types.len() == 2 {
               match arg_types[0].clone() {
                   Decimal128(p, s) => Ok(vec![Decimal128(p, s), Int64]),
                   Decimal256(p, s) => Ok(vec![Decimal256(p, s), Int64]),
                   Float32 => Ok(vec![Float32, Int64]),
                   _ => Ok(vec![Float64, Int64]),
               }
           } else {
               exec_err!(
                   "round function requires one or two arguments, got {}",
                   arg_types.len()
               )
           }
       }
   ```



-- 
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