Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ abstract class Expression extends TreeNode[Expression] {
*/
trait Unevaluable extends Expression {

override def eval(input: InternalRow = null): Any =
final override def eval(input: InternalRow = null): Any =
throw new UnsupportedOperationException(s"Cannot evaluate expression: $this")

override protected def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): String =
final override protected def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): String =
throw new UnsupportedOperationException(s"Cannot evaluate expression: $this")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ private[sql] case object Complete extends AggregateMode
*/
private[sql] case object NoOp extends Expression with Unevaluable {
override def nullable: Boolean = true
override def eval(input: InternalRow): Any = {
throw new TreeNodeException(
this, s"No function to evaluate expression. type: ${this.nodeName}")
}
override def dataType: DataType = NullType
override def children: Seq[Expression] = Nil
}
Expand Down Expand Up @@ -151,8 +147,7 @@ abstract class AggregateFunction2
/**
* A helper class for aggregate functions that can be implemented in terms of catalyst expressions.
*/
abstract class AlgebraicAggregate extends AggregateFunction2 with Serializable {
self: Product =>
abstract class AlgebraicAggregate extends AggregateFunction2 with Serializable with Unevaluable {

val initialValues: Seq[Expression]
val updateExpressions: Seq[Expression]
Expand Down Expand Up @@ -188,19 +183,15 @@ abstract class AlgebraicAggregate extends AggregateFunction2 with Serializable {
}
}

override def update(buffer: MutableRow, input: InternalRow): Unit = {
override final def update(buffer: MutableRow, input: InternalRow): Unit = {
throw new UnsupportedOperationException(
"AlgebraicAggregate's update should not be called directly")
}

override def merge(buffer1: MutableRow, buffer2: InternalRow): Unit = {
override final def merge(buffer1: MutableRow, buffer2: InternalRow): Unit = {
throw new UnsupportedOperationException(
"AlgebraicAggregate's merge should not be called directly")
}

override def eval(buffer: InternalRow): Any = {
throw new UnsupportedOperationException(
"AlgebraicAggregate's eval should not be called directly")
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package org.apache.spark.sql.catalyst.expressions
import com.clearspring.analytics.stream.cardinality.HyperLogLog

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.errors.TreeNodeException
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
import org.apache.spark.sql.catalyst.expressions.codegen.{CodeGenContext, GeneratedExpressionCode}
import org.apache.spark.sql.catalyst.util.TypeUtils
import org.apache.spark.sql.types._
import org.apache.spark.util.collection.OpenHashSet
Expand Down Expand Up @@ -71,8 +71,7 @@ trait PartialAggregate1 extends AggregateExpression1 {
* A specific implementation of an aggregate function. Used to wrap a generic
* [[AggregateExpression1]] with an algorithm that will be used to compute one specific result.
*/
abstract class AggregateFunction1
extends LeafExpression with AggregateExpression1 with Serializable {
abstract class AggregateFunction1 extends LeafExpression with Serializable {

/** Base should return the generic aggregate expression that this function is computing */
val base: AggregateExpression1
Expand All @@ -82,9 +81,9 @@ abstract class AggregateFunction1

def update(input: InternalRow): Unit

// Do we really need this?
override def newInstance(): AggregateFunction1 = {
makeCopy(productIterator.map { case a: AnyRef => a }.toArray)
override protected def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): String = {
throw new UnsupportedOperationException(
"AggregateFunction1 should not be used for generated aggregates")
}
}

Expand Down