Jefffrey commented on PR #18999: URL: https://github.com/apache/datafusion/pull/18999#issuecomment-3620246029
> Ok, instead of converting to float I'll keep it as integers and perform and integer log. > > Just one thing though the `log` function in DuckDB and Clickhouse return `float64/double` so the behaviour might different (but I personally think that's fine, as the user will not have an implicit type conversion from decimal to float). And if we are returning as decimal then the following is expected right? across Decimal32, Decimal64, Decimal128, Decimal256 > > | Query | Res | > |----------------------------------|-------| > | select log(12345::decimal(38,0)) | 4.0 | > | select log(12345::decimal(38,2)) | 4.09 | > > I went through the Intel and IBM solution to understand potential edge cases which could affect precision. I won't be porting anything from them unless it's truly needed, point noted I think we should follow what the decimal128 version is doing: it performs ilog on the scaled i128 and then converts it to f64 to return. We aren't returning log of decimal as log, we're still converting it to f64. The idea is that doing the log as ilog on scaled decimal we get more accurate results than casting decimal to float before performing log on the float. See the original decimal128 PR for reference. -- 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]
