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

    https://github.com/apache/spark/pull/737#discussion_r12546014
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala
 ---
    @@ -269,6 +308,34 @@ case class CountFunction(expr: Expression, base: 
AggregateExpression) extends Ag
       override def eval(input: Row): Any = count
     }
     
    +case class ApproxCountDistinctPartitionFunction(expr: Expression, base: 
AggregateExpression)
    +    extends AggregateFunction {
    +  def this() = this(null, null) // Required for serialization.
    +
    +  private val hyperLogLog = new HyperLogLog(ApproxCountDistinct.RelativeSD)
    +
    +  override def update(input: Row): Unit = {
    +    val evaluatedExpr = expr.eval(input)
    +    Option(evaluatedExpr).foreach(hyperLogLog.offer(_))
    +  }
    +
    +  override def eval(input: Row): Any = hyperLogLog
    +}
    +
    +case class ApproxCountDistinctMergeFunction(expr: Expression, base: 
AggregateExpression)
    +    extends AggregateFunction {
    +  def this() = this(null, null) // Required for serialization.
    +
    +  private val hyperLogLog = new HyperLogLog(ApproxCountDistinct.RelativeSD)
    +
    +  override def update(input: Row): Unit = {
    +    val evaluatedExpr = expr.eval(input)
    +    
Option(evaluatedExpr.asInstanceOf[HyperLogLog]).foreach(hyperLogLog.addAll(_))
    --- End diff --
    
    Will this ever be null?


---
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.
---

Reply via email to