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

    https://github.com/apache/spark/pull/18113#discussion_r118800681
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/typedaggregators.scala
 ---
    @@ -99,3 +97,67 @@ class TypedAverage[IN](val f: IN => Double) extends 
Aggregator[IN, (Double, Long
         toColumn.asInstanceOf[TypedColumn[IN, java.lang.Double]]
       }
     }
    +
    +class TypedMinDouble[IN](val f: IN => Double) extends Aggregator[IN, 
Double, Double] {
    +  override def zero: Double = Double.PositiveInfinity
    +  override def reduce(b: Double, a: IN): Double = if (b < f(a)) b else f(a)
    +  override def merge(b1: Double, b2: Double): Double = if (b1 < b2) b1 
else b2
    +  override def finish(reduction: Double): Double = reduction
    +
    +  override def bufferEncoder: Encoder[Double] = ExpressionEncoder[Double]()
    +  override def outputEncoder: Encoder[Double] = ExpressionEncoder[Double]()
    +
    +  // Java api support
    +  def this(f: MapFunction[IN, java.lang.Double]) = this(x => 
f.call(x).asInstanceOf[Double])
    +  def toColumnJava: TypedColumn[IN, java.lang.Double] = {
    +    toColumn.asInstanceOf[TypedColumn[IN, java.lang.Double]]
    +  }
    +}
    +
    +class TypedMaxDouble[IN](val f: IN => Double) extends Aggregator[IN, 
Double, Double] {
    +  override def zero: Double = Double.NegativeInfinity
    +  override def reduce(b: Double, a: IN): Double = if (b > f(a)) b else f(a)
    +  override def merge(b1: Double, b2: Double): Double = if (b1 > b2) b1 
else b2
    +  override def finish(reduction: Double): Double = reduction
    +
    +  override def bufferEncoder: Encoder[Double] = ExpressionEncoder[Double]()
    +  override def outputEncoder: Encoder[Double] = ExpressionEncoder[Double]()
    +
    +  // Java api support
    +  def this(f: MapFunction[IN, java.lang.Double]) = this(x => 
f.call(x).asInstanceOf[Double])
    +  def toColumnJava: TypedColumn[IN, java.lang.Double] = {
    +    toColumn.asInstanceOf[TypedColumn[IN, java.lang.Double]]
    +  }
    +}
    +
    +class TypedMinLong[IN](val f: IN => Long) extends Aggregator[IN, Long, 
Long] {
    +  override def zero: Long = Long.MaxValue
    +  override def reduce(b: Long, a: IN): Long = if (b < f(a)) b else f(a)
    +  override def merge(b1: Long, b2: Long): Long = if (b1 < b2) b1 else b2
    +  override def finish(reduction: Long): Long = reduction
    +
    +  override def bufferEncoder: Encoder[Long] = ExpressionEncoder[Long]()
    +  override def outputEncoder: Encoder[Long] = ExpressionEncoder[Long]()
    +
    +  // Java api support
    +  def this(f: MapFunction[IN, java.lang.Long]) = this(x => 
f.call(x).asInstanceOf[Long])
    +  def toColumnJava: TypedColumn[IN, java.lang.Long] = {
    +    toColumn.asInstanceOf[TypedColumn[IN, java.lang.Long]]
    +  }
    +}
    +
    +class TypedMaxLong[IN](val f: IN => Long) extends Aggregator[IN, Long, 
Long] {
    +  override def zero: Long = Long.MinValue
    +  override def reduce(b: Long, a: IN): Long = if (b > f(a)) b else f(a)
    +  override def merge(b1: Long, b2: Long): Long = if (b1 > b2) b1 else b2
    +  override def finish(reduction: Long): Long = reduction
    +
    +  override def bufferEncoder: Encoder[Long] = ExpressionEncoder[Long]()
    +  override def outputEncoder: Encoder[Long] = ExpressionEncoder[Long]()
    +
    +  // Java api support
    +  def this(f: MapFunction[IN, java.lang.Long]) = this(x => 
f.call(x).asInstanceOf[Long])
    +  def toColumnJava: TypedColumn[IN, java.lang.Long] = {
    +    toColumn.asInstanceOf[TypedColumn[IN, java.lang.Long]]
    +  }
    +}
    --- End diff --
    
    Add a new line here.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to