kumarUjjawal commented on code in PR #22276:
URL: https://github.com/apache/datafusion/pull/22276#discussion_r3408100832
##########
datafusion/functions/src/math/log.rs:
##########
Review Comment:
This rewrite can skip the new error. log(-2.0, -2.0) should error, but this
can simplify to 1. Please keep the original expression unless the value and
base are proven valid
##########
datafusion/functions/src/math/log.rs:
##########
@@ -247,27 +273,24 @@ impl ScalarUDFImpl for LogFunc {
let value = value.to_array(args.number_rows)?;
let output: ArrayRef = match value.data_type() {
- DataType::Float16 => {
- calculate_binary_math::<Float16Type, Float16Type, Float16Type,
_>(
- &value,
- &base,
- |value, base| Ok(value.log(base)),
- )?
- }
- DataType::Float32 => {
- calculate_binary_math::<Float32Type, Float32Type, Float32Type,
_>(
- &value,
- &base,
- |value, base| Ok(value.log(base)),
- )?
- }
- DataType::Float64 => {
- calculate_binary_math::<Float64Type, Float64Type, Float64Type,
_>(
- &value,
- &base,
- |value, base| Ok(value.log(base)),
- )?
- }
+ DataType::Float16 => calculate_binary_math::<
+ Float16Type,
+ Float16Type,
+ Float16Type,
+ _,
+ >(&value, &base, checked_log)?,
+ DataType::Float32 => calculate_binary_math::<
+ Float32Type,
+ Float32Type,
+ Float32Type,
+ _,
+ >(&value, &base, checked_log)?,
+ DataType::Float64 => calculate_binary_math::<
+ Float64Type,
+ Float64Type,
+ Float64Type,
+ _,
+ >(&value, &base, checked_log)?,
Review Comment:
This rewrite can skip the new error. log(-2.0, power(-2.0, 3.0)) should
error because the log value is negative, but this can simplify to 3.0. Please
only rewrite when the log domain is proven valid.
--
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]