@@ -20,30 +20,30 @@ package org.apache.spark.sql.catalyst.expressions.aggregate2
2020import org .apache .spark .sql .catalyst .dsl .expressions ._
2121import org .apache .spark .sql .catalyst .errors .TreeNodeException
2222import org .apache .spark .sql .catalyst .expressions ._
23- import org .apache .spark .sql .catalyst .{CatalystTypeConverters , InternalRow }
23+ import org .apache .spark .sql .catalyst .expressions .codegen .{GeneratedExpressionCode , CodeGenContext }
24+ import org .apache .spark .sql .catalyst .InternalRow
2425import org .apache .spark .sql .types ._
25- import org .apache .spark .sql .Row
2626
27- /** The mode of an [[AggregateFunction ]]. */
27+ /** The mode of an [[AggregateFunction1 ]]. */
2828private [sql] sealed trait AggregateMode
2929
3030/**
31- * An [[AggregateFunction ]] with [[Partial ]] mode is used for partial aggregation.
31+ * An [[AggregateFunction1 ]] with [[Partial ]] mode is used for partial aggregation.
3232 * This function updates the given aggregation buffer with the original input of this
3333 * function. When it has processed all input rows, the aggregation buffer is returned.
3434 */
3535private [sql] case object Partial extends AggregateMode
3636
3737/**
38- * An [[AggregateFunction ]] with [[PartialMerge ]] mode is used to merge aggregation buffers
38+ * An [[AggregateFunction1 ]] with [[PartialMerge ]] mode is used to merge aggregation buffers
3939 * containing intermediate results for this function.
4040 * This function updates the given aggregation buffer by merging multiple aggregation buffers.
4141 * When it has processed all input rows, the aggregation buffer is returned.
4242 */
4343private [sql] case object PartialMerge extends AggregateMode
4444
4545/**
46- * An [[AggregateFunction ]] with [[PartialMerge ]] mode is used to merge aggregation buffers
46+ * An [[AggregateFunction1 ]] with [[PartialMerge ]] mode is used to merge aggregation buffers
4747 * containing intermediate results for this function and the generate final result.
4848 * This function updates the given aggregation buffer by merging multiple aggregation buffers.
4949 * When it has processed all input rows, the final result of this function is returned.
@@ -58,7 +58,7 @@ private[sql] case object Final extends AggregateMode
5858 */
5959private [sql] case object Complete extends AggregateMode
6060
61- private [sql] case object NoOp extends Expression {
61+ private [sql] case object NoOp extends Expression with Unevaluable {
6262 override def nullable : Boolean = true
6363 override def eval (input : InternalRow ): Any = {
6464 throw new TreeNodeException (
@@ -78,19 +78,14 @@ private[sql] case object NoOp extends Expression {
7878private [sql] case class AggregateExpression2 (
7979 aggregateFunction : AggregateFunction2 ,
8080 mode : AggregateMode ,
81- isDistinct : Boolean ) extends Expression {
81+ isDistinct : Boolean ) extends Expression with Unevaluable {
8282
8383 override def children : Seq [Expression ] = aggregateFunction :: Nil
8484 override def dataType : DataType = aggregateFunction.dataType
8585 override def foldable : Boolean = false
8686 override def nullable : Boolean = aggregateFunction.nullable
8787
8888 override def toString : String = s " ( ${aggregateFunction}2,mode= $mode,isDistinct= $isDistinct) "
89-
90- override def eval (input : InternalRow = null ): Any = {
91- throw new TreeNodeException (
92- this , s " No function to evaluate expression. type: ${this .nodeName}" )
93- }
9489}
9590
9691abstract class AggregateFunction2
@@ -136,6 +131,9 @@ abstract class AggregateFunction2
136131 * and `buffer2`.
137132 */
138133 def merge (buffer1 : MutableRow , buffer2 : InternalRow ): Unit
134+
135+ override protected def genCode (ctx : CodeGenContext , ev : GeneratedExpressionCode ): String =
136+ throw new UnsupportedOperationException (s " Cannot evaluate expression: $this" )
139137}
140138
141139/**
0 commit comments