Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression in AnsiCastOpSuite with Spark 3.3.0 #5486

Merged
merged 1 commit into from
May 16, 2022
Merged
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
15 changes: 12 additions & 3 deletions tests/src/test/scala/com/nvidia/spark/rapids/AnsiCastOpSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -795,11 +795,20 @@ class AnsiCastOpSuite extends GpuExpressionTestSuite {
case _: ProjectExec | _: GpuProjectExec => true
case _ => false
})

def isAnsiCast(c: CastBase): Boolean = {
// prior to Spark 3.3.0 we could use toString to see if the name of
// the cast was "cast" or "ansi_cast" but now the name is always "cast"
// so we need to use reflection to access the protected field "ansiEnabled"
val m = c.getClass.getDeclaredField("ansiEnabled")
m.setAccessible(true)
m.getBoolean(c)
}

val count = projections.map {
case p: ProjectExec => p.projectList.count {
// ansiEnabled is protected so we rely on CastBase.toString
case c: CastBase => c.toString().startsWith("ansi_cast")
case Alias(c: CastBase, _) => c.toString().startsWith("ansi_cast")
case c: CastBase => isAnsiCast(c)
tgravescs marked this conversation as resolved.
Show resolved Hide resolved
case Alias(c: CastBase, _) => isAnsiCast(c)
case _ => false
}
case p: GpuProjectExec => p.projectList.count {
Expand Down