comphead commented on code in PR #67:
URL: https://github.com/apache/datafusion-spark/pull/67#discussion_r4566026191
##########
crates/spark/src/function/math/pow.rs:
##########
@@ -112,20 +110,11 @@ impl ScalarUDFImpl for SparkPow {
.downcast_ref::<Float64Array>()
.expect("exponent must be Float64Array");
- // Spark: 0^negative = +Infinity (covers both 0.0 and -0.0)
- // IEEE 754: 0.0^-1.0 = +Infinity, -0.0^-1.0 = -Infinity
- // Thus we need an explicit guard for base == 0.0 to ensure +Infinity.
let result: Float64Array = base_f64
.iter()
.zip(exp_f64.iter())
.map(|(base, exp)| match (base, exp) {
- (Some(base), Some(exp)) => {
- if base == 0.0 && exp < 0.0 {
- Some(f64::INFINITY)
- } else {
- Some(base.powf(exp))
- }
- }
+ (Some(base), Some(exp)) => Some(spark_pow(base, exp)),
Review Comment:
Now that the whole row is one `spark_pow` call, the zip and `collect` could
be `arrow::compute::binary(base_f64, exp_f64, spark_pow)?`. That builds the
null buffer as a bitmap union instead of an `Option` per row, and gives a tight
loop over the values. I have not measured it here.
--
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]