Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20756#discussion_r177302845
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ObjectExpressionsSuite.scala
 ---
    @@ -68,6 +68,32 @@ class ObjectExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper {
           mapEncoder.serializer.head, mapExpected, mapInputRow)
       }
     
    +  test("SPARK-23593: InitializeJavaBean should support interpreted 
execution") {
    +    val list = new java.util.LinkedList[Int]()
    +    list.add(1)
    +
    +    val initializeBean = InitializeJavaBean(Literal.fromObject(new 
java.util.LinkedList[Int]),
    +      Map("add" -> Literal(1)))
    +    checkEvaluation(initializeBean, list, InternalRow.fromSeq(Seq()))
    +
    +    val initializeWithNonexistingMethod = InitializeJavaBean(
    +      Literal.fromObject(new java.util.LinkedList[Int]),
    +      Map("nonexisting" -> Literal(1)))
    +    checkExceptionInExpression[Exception](initializeWithNonexistingMethod,
    +      InternalRow.fromSeq(Seq()),
    +      """A method named "nonexisting" is not declared in any enclosing 
class """ +
    +        "nor any supertype")
    +
    +    val initializeWithWrongParamType = InitializeJavaBean(
    +      Literal.fromObject(new TestBean),
    +      Map("setX" -> Literal("1")))
    +    intercept[Exception] {
    +      evaluateWithoutCodegen(initializeWithWrongParamType, 
InternalRow.fromSeq(Seq()))
    +    }.getMessage.contains(
    --- End diff --
    
    For codegen the compile exception is like:
    ```
    No applicable constructor/method found for actual parameters 
"org.apache.spark.unsafe.types.UTF8String"; candidates are: "public void 
org.apache.spark.sql.catalyst.expressions.TestBean.setX(int)"
    ```
    
    I'm not sure if we want to exactly match this kind of exception message 
from interpreted execution. Might be a little overkill to do that by looking 
methods with same name. So currently I only test interpreted execution.


---

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

Reply via email to