theirix opened a new pull request, #17023: URL: https://github.com/apache/datafusion/pull/17023
## Which issue does this PR close? - Closes #. ## Rationale for this change Add Decimal128 and Decimal256 support for `log` UDF. It's a most generic function, allowing for specifying a logarithm base, but by default it is `log10`, which makes it a good candidate for long decimals. Currently, it only supports floats. Since decimals only support integer logarithms, it's rounded and then converted back to a float. Also, if numbers are parsed as floats, there is precision lost due to floating-point handling. So the majority of tests are targeting `parse_float_as_decimal=true` as in #14612. Otherwise, the log could differ by one or two due to rounding – see regression SLT. Notably, we still miss math for 256-bits. [Arrow's i256 type](https://arrow.apache.org/rust/arrow_buffer/bigint/index.html) uses the [BigInt implementation], which could provide [log10](https://github.com/rust-num/num-bigint/issues/57) at least, but we can extend decimal arithmetic in Arrow as well. ## What changes are included in this PR? - Support for decimals - Additional unit tests - A minor follow-up fix to #16831 for zero scale - [chore] Allow env logging in functions crate Please note, there are [more specialised](https://github.com/apache/datafusion/blob/6d9b76e4a30f6234ffa3f8100b5d4c2735558ca6/datafusion/functions/src/math/mod.rs#L178) functions `log2`, `log10`, `ln` (), which are not handled by `LogFunc`. They could be migrated to this UDF later, providing a base value explicitly. ## Are these changes tested? - Unit tests - Regression SLT tests - Manual invocation of datafusion-cli - Manual comparison of results to other large decimal math implementations (Python, WolframAlpha) ## Are there any user-facing changes? No -- 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