cloud-fan commented on a change in pull request #34894:
URL: https://github.com/apache/spark/pull/34894#discussion_r821681968
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/linearRegression.scala
##########
@@ -105,3 +106,34 @@ case class RegrAvgY(left: Expression, right: Expression)
newLeft: Expression, newRight: Expression): RegrAvgY =
this.copy(left = newLeft, right = newRight)
}
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+ usage = "_FUNC_(y, x) - Returns the number of non-null number pairs in a
group, where `y` is the dependent variable and `x` is the independent
variable.",
+ examples = """
+ Examples:
+ > SELECT _FUNC_(y, x) FROM VALUES (1, 2), (2, 2), (2, 3), (2, 4) AS
tab(y, x);
+ 0.2727272727272727
+ > SELECT _FUNC_(y, x) FROM VALUES (1, null) AS tab(y, x);
+ NULL
+ > SELECT _FUNC_(y, x) FROM VALUES (null, 1) AS tab(y, x);
+ NULL
+ > SELECT _FUNC_(y, x) FROM VALUES (1, 2), (2, null), (2, 3), (2, 4) AS
tab(y, x);
+ 0.7500000000000001
+ > SELECT _FUNC_(y, x) FROM VALUES (1, 2), (2, null), (null, 3), (2, 4)
AS tab(y, x);
+ 1.0
+ """,
+ group = "agg_funcs",
+ since = "3.3.0")
+// scalastyle:on line.size.limit
+case class RegrR2(x: Expression, y: Expression) extends PearsonCorrelation(x,
y, true) {
+ override def prettyName: String = "regr_r2"
+ override val evaluateExpression: Expression = {
+ lazy val corr = ck / sqrt(xMk * yMk)
Review comment:
We are building expressions here, not calculating the result. I don't
this lazy val is necessary.
--
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]