You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/03/22 18:28:32 UTC

[GitHub] [spark] viirya commented on a change in pull request #31888: [SPARK-34596][SQL][2.4] Use Utils.getSimpleName to avoid hitting Malformed class name in NewInstance.doGenCode

viirya commented on a change in pull request #31888:
URL: https://github.com/apache/spark/pull/31888#discussion_r598974589



##########
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:
       Is this the compilation error?
   
   ```
   [info]   Cause: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 32, Column 124: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 32, Column 124: "org.apache.
   spark.sql.catalyst.encoders.ExpressionEncoderSuite$MalformedClassObject$" has no member type "ExpressionEncoderSuite$MalformedClassObject$MalformedNameExample"
   ```




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org