Mark1626 commented on PR #18999: URL: https://github.com/apache/datafusion/pull/18999#issuecomment-3605220826
> Now that I think about it, how would this implementation be different from having our coercion/casting logic convert the input decimal arrays to floats before applying the log My take here is that it would depend on the function. Let's say something `round`, `ceil`, `floor` a coercion is unacceptable, where as with things like `log`, `sin` the results would not be precise and so a coercion is acceptable We can doing it entirely in decimal like this one based on IBM's version https://github.com/semihc/CppDecimal/blob/main/src/decNumber.c#L1384-L1518 But I think this would be a rather expensive version. Also from https://github.com/apache/datafusion/issues/18524 if we want `select log(2.0, 100000000000000000000000000000000000::decimal(38,0));` to be `116.267483321058` we need the result of `log` to be float (which it currently is), otherwise I think the result has to be `116` (since it's (38, 0)) --- Another thing is Intel's decimal library does convert `decimal -> binary64` then back to `decimal`. The conversion itself is a bit more sophisticated than a simple (N / 10*scale) https://github.com/karlorz/IntelRDFPMathLib20U2/blob/main/LIBRARY/src/bid32_log.c We can port their conversion logic here if needed, I wanted to get some feedback on this PR before that. Let me know your suggestion on this -- 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]
