Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Huaxin Gao committed Apr 29, 2024
1 parent fd77252 commit de7bd71
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/src/execution/datafusion/expressions/stddev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ use crate::execution::datafusion::expressions::utils::down_cast_any_ref;
use crate::execution::datafusion::expressions::variance::VarianceAccumulator;

/// STDDEV and STDDEV_SAMP (standard deviation) aggregate expression
/// The implementation mostly is the same as the DataFusion's implementation. The reason
/// we have our own implementation is that DataFusion has UInt64 for state_field `count`,
/// while Spark has Double for count. Also we have added `null_on_divide_by_zero`
/// to be consistent with Spark's implementation.
#[derive(Debug)]
pub struct Stddev {
name: String,
Expand Down Expand Up @@ -112,7 +116,10 @@ impl PartialEq<dyn Any> for Stddev {
fn eq(&self, other: &dyn Any) -> bool {
down_cast_any_ref(other)
.downcast_ref::<Self>()
.map(|x| self.name == x.name && self.expr.eq(&x.expr))
.map(|x|
self.name == x.name
&& self.expr.eq(&x.expr)
&& self.null_on_divide_by_zero == x.null_on_divide_by_zero)
.unwrap_or(false)
}
}
Expand Down
2 changes: 2 additions & 0 deletions docs/source/user-guide/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ The following Spark expressions are currently available:
- CovSample
- VariancePop
- VarianceSamp
- StddevPop
- StddevSamp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde {
.setStddev(stdBuilder)
.build())
} else {
withInfo(aggExpr, child)
None
}
case std @ StddevPop(child, nullOnDivideByZero) =>
Expand All @@ -540,6 +541,7 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde {
.setStddev(stdBuilder)
.build())
} else {
withInfo(aggExpr, child)
None
}
case fn =>
Expand Down

0 comments on commit de7bd71

Please sign in to comment.