viirya commented on a change in pull request #31888:
URL: https://github.com/apache/spark/pull/31888#discussion_r598979104
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/ExpressionEncoderSuite.scala
##########
@@ -203,6 +203,36 @@ class ExpressionEncoderSuite extends
CodegenInterpretedPlanTest with AnalysisTes
encodeDecodeTest(Array(Option(InnerClass(1))), "array of optional inner
class")
+ // NOTE: branch-2.4 does not have the interpreted implementation of
SafeProjection, so
+ // it does not fall back into the interpreted mode if the compilation fails.
+ // Therefore, the test in this PR just checks that the compilation error
happens
+ // instead of checking that the interpreted mode works well.
+ private def checkCompilationError[T : ExpressionEncoder](
+ input: T,
+ testName: String): Unit = {
+ testAndVerifyNotLeakingReflectionObjects(s"compilation error: $testName:
$input") {
+ val encoder = implicitly[ExpressionEncoder[T]]
+ val row = encoder.toRow(input)
+ val boundEncoder = encoder.resolveAndBind()
+ val errMsg = intercept[RuntimeException] {
+ boundEncoder.fromRow(row)
+ }.getCause.getMessage
+ assert(errMsg.contains("failed to compile: "))
Review comment:
But by moving `MalformedClassObject` out of `ExpressionEncoderSuite`,
the generated code can be compiled.
I'm not sure what this test wants to test actually. Am I confused or do I
misunderstand it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]