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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ trait ExpressionEvalHelper extends GeneratorDrivenPropertyChecks {
}

protected def checkEvaluation(
expression: => Expression, expected: Any, inputRow: InternalRow = EmptyRow): Unit = {
originalExpr: => Expression, expected: Any, inputRow: InternalRow = EmptyRow): Unit = {
val expression = originalExpr match {
case replaceable: RuntimeReplaceable => replaceable.replaced
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you write a test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any test for testing harness in Spark though, but I can do it in a separate pull request if it is needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, do we have a test that pass in RuntimeReplaceable to checkEvaluation? Or how can we know this works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when we add one that uses this it will fail if it doesn't work?

I can also remove this if you think it's better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we add one that uses this it will fail if it doesn't work

Yea, I also checked all the implementations of RuntimeReplaceable and they don't have unit test. It will be good if we can test them and verify the checkEvaluation can work with RuntimeReplaceable after your change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are already tested in the end-to-end tests. I'm not sure if expression level unit tests are useful, given they are replaced in the optimizer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, I removed RuntimeReplaceable here.

case _ => originalExpr
}

val catalystValue = CatalystTypeConverters.convertToCatalyst(expected)
checkEvaluationWithoutCodegen(expression, catalystValue, inputRow)
checkEvaluationWithGeneratedMutableProjection(expression, catalystValue, inputRow)
Expand All @@ -63,6 +68,10 @@ trait ExpressionEvalHelper extends GeneratorDrivenPropertyChecks {
expected.asInstanceOf[Spread[Double]].isWithin(result)
case (result: MapData, expected: MapData) =>
result.keyArray() == expected.keyArray() && result.valueArray() == expected.valueArray()
case (result: Double, expected: Double) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoud we also handle isInfinite

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scala> Double.PositiveInfinity == Double.PositiveInfinity
res2: Boolean = true

it already works

if (expected.isNaN) result.isNaN else expected == result
case (result: Float, expected: Float) =>
if (expected.isNaN) result.isNaN else expected == result
case _ =>
result == expected
}
Expand Down