Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8587#discussion_r43162805
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/functions.scala
 ---
    @@ -524,6 +525,133 @@ case class Sum(child: Expression) extends 
DeclarativeAggregate {
       override val evaluateExpression = Cast(currentSum, resultType)
     }
     
    +/**
    + * Compute Pearson correlation between two expressions.
    + * When applied on empty data (i.e., count is zero), it returns NaN.
    + *
    + * Definition of Pearson correlation can be found at
    + * 
http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient
    + *
    + * @param left one of the expressions to compute correlation with.
    + * @param right another expression to compute correlation with.
    + */
    +case class Corr(
    +    left: Expression,
    +    right: Expression,
    +    mutableAggBufferOffset: Int = 0,
    +    inputAggBufferOffset: Int = 0)
    +  extends ImperativeAggregate {
    +
    +  def children: Seq[Expression] = Seq(left, right)
    +
    +  def nullable: Boolean = false
    +
    +  def dataType: DataType = DoubleType
    +
    +  def inputTypes: Seq[AbstractDataType] = Seq(DoubleType)
    --- End diff --
    
    Probably we need to do something like what we have done in `AVERAGE` 
(https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/functions.scala#L40-L52).


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to