Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Reset the changes in ExpressionEvalHelper.
  • Loading branch information
rxin committed Jul 27, 2015
commit 0f57c556d15f1c1294e07b44fdd9e41c461d2dfd
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,21 @@ trait ExpressionEvalHelper {
}

protected def checkEvalutionWithUnsafeProjection(
expression: Expression,
expected: Any,
inputRow: InternalRow = EmptyRow): Unit = {
expression: Expression,
expected: Any,
inputRow: InternalRow = EmptyRow): Unit = {

val project = generateProject(
val plan = generateProject(
GenerateUnsafeProjection.generate(Alias(expression, s"Optimized($expression)")() :: Nil),
expression)
val out = project(inputRow)
val input = if (inputRow == EmptyRow) "" else s", input: $inputRow"

if (expected == null) {
if (!out.isNullAt(0)) {
val actual = out.get(0, expression.dataType)
fail(s"Incorrect Evaluation: $expression, actual: $actual, expected: $expected$input")
}
} else if (out.get(0, expression.dataType) != expected) {
val actual = out.get(0, expression.dataType)
fail(s"Incorrect Evaluation: $expression, actual: $actual, expected: $expected$input")

val unsafeRow = plan(inputRow)
// UnsafeRow cannot be compared with GenericInternalRow directly
val actual = FromUnsafeProjection(expression.dataType :: Nil)(unsafeRow)
val expectedRow = InternalRow(expected)
if (actual != expectedRow) {
val input = if (inputRow == EmptyRow) "" else s", input: $inputRow"
fail(s"Incorrect Evaluation: $expression, actual: $actual, expected: $expectedRow$input")
}
}

Expand All @@ -187,9 +184,9 @@ trait ExpressionEvalHelper {
}

protected def checkDoubleEvaluation(
expression: => Expression,
expected: Spread[Double],
inputRow: InternalRow = EmptyRow): Unit = {
expression: => Expression,
expected: Spread[Double],
inputRow: InternalRow = EmptyRow): Unit = {
checkEvaluationWithoutCodegen(expression, expected)
checkEvaluationWithGeneratedMutableProjection(expression, expected)
checkEvaluationWithOptimization(expression, expected)
Expand All @@ -203,7 +200,8 @@ trait ExpressionEvalHelper {
plan = generateProject(
GenerateUnsafeProjection.generate(Alias(expression, s"Optimized($expression)")() :: Nil),
expression)
actual = plan(inputRow).get(0, expression.dataType)
actual = FromUnsafeProjection(expression.dataType :: Nil)(
plan(inputRow)).get(0, expression.dataType)
assert(checkResult(actual, expected))
}
}