cloud-fan commented on a change in pull request #34882:
URL: https://github.com/apache/spark/pull/34882#discussion_r821465089
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/linearRegression.scala
##########
@@ -105,3 +106,100 @@ case class RegrAvgY(left: Expression, right: Expression)
newLeft: Expression, newRight: Expression): RegrAvgY =
this.copy(left = newLeft, right = newRight)
}
+
+abstract class Regression
+ extends DeclarativeAggregate with ImplicitCastInputTypes with
BinaryLike[Expression] {
+
+ override def nullable: Boolean = true
+ override def dataType: DataType = DoubleType
+ override def inputTypes: Seq[AbstractDataType] = Seq(DoubleType, DoubleType)
+
+ protected val count = AttributeReference("count", DoubleType)()
+ protected val meanX = AttributeReference("meanX", DoubleType)()
+ protected val meanY = AttributeReference("meanY", DoubleType)()
+ protected val c2 = AttributeReference("c2", DoubleType)()
+ protected val m2X = AttributeReference("m2X", DoubleType)()
+
+ override val aggBufferAttributes: Seq[AttributeReference] = Seq(count,
meanX, meanY, c2, m2X)
+
+ override val initialValues: Seq[Expression] = Array.fill(5)(Literal(0.0))
+
+ override lazy val updateExpressions: Seq[Expression] = {
Review comment:
do you follow any reference implementation? This doesn't seem like
following https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
--
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]