Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/10960#discussion_r51547587
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/CentralMomentAgg.scala
---
@@ -52,178 +50,162 @@ abstract class CentralMomentAgg(child: Expression)
extends ImperativeAggregate w
protected def momentOrder: Int
override def children: Seq[Expression] = Seq(child)
-
override def nullable: Boolean = true
-
override def dataType: DataType = DoubleType
+ override def inputTypes: Seq[AbstractDataType] = Seq(DoubleType)
+
+ protected val n = AttributeReference("n", DoubleType, nullable = false)()
+ protected val avg = AttributeReference("avg", DoubleType, nullable =
false)()
+ protected val m2 = AttributeReference("m2", DoubleType, nullable =
false)()
+ protected val m3 = AttributeReference("m3", DoubleType, nullable =
false)()
+ protected val m4 = AttributeReference("m4", DoubleType, nullable =
false)()
+
+ private def trimHigherOrder[T](expressions: Seq[T]) =
expressions.take(momentOrder + 1)
+
+ override val aggBufferAttributes = trimHigherOrder(Seq(n, avg, m2, m3,
m4))
+
+ override val initialValues: Seq[Expression] =
+ trimHigherOrder(Seq(Literal(0.0), Literal(0.0), Literal(0.0),
Literal(0.0), Literal(0.0)))
--- End diff --
Sorry for some miscommunication. The previous inline comments are useful
here because `Lit(0.0)` carries no information. The comments are not necessary
when the variable names can clearly tell what they are. Please recover the
inline comments for initial values.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]