cloud-fan commented on code in PR #47105: URL: https://github.com/apache/spark/pull/47105#discussion_r1666496032
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/linearRegression.scala: ########## @@ -271,8 +271,12 @@ case class RegrSlope(left: Expression, right: Expression) extends DeclarativeAgg override lazy val initialValues: Seq[Expression] = covarPop.initialValues ++ varPop.initialValues - override lazy val updateExpressions: Seq[Expression] = - covarPop.updateExpressions ++ varPop.updateExpressions + override lazy val updateExpressions: Seq[Expression] = { + val isNull = left.isNull || right.isNull + covarPop.updateExpressions ++ varPop.updateExpressions.zip(varPop.aggBufferAttributes).map { + case (newValue, oldValue) => If(isNull, oldValue, newValue) Review Comment: let's add some code comments to explain the null check ########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/linearRegression.scala: ########## @@ -324,8 +328,12 @@ case class RegrIntercept(left: Expression, right: Expression) extends Declarativ override lazy val initialValues: Seq[Expression] = covarPop.initialValues ++ varPop.initialValues - override lazy val updateExpressions: Seq[Expression] = - covarPop.updateExpressions ++ varPop.updateExpressions + override lazy val updateExpressions: Seq[Expression] = { + val isNull = left.isNull || right.isNull + covarPop.updateExpressions ++ varPop.updateExpressions.zip(varPop.aggBufferAttributes).map { + case (newValue, oldValue) => If(isNull, oldValue, newValue) Review Comment: ditto -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org