You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2023/07/24 13:43:41 UTC

[GitHub] [spark] pan3793 opened a new pull request, #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

pan3793 opened a new pull request, #42128:
URL: https://github.com/apache/spark/pull/42128

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   This PR aims to improve the error message when `Invoke` method is not found.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   Currently, the error message is not clear when `Invoke` method is not found.
   
   There is one error message I have encountered, which is not much helpful to find the root cause.
   ```
   org.apache.spark.SparkException: [INTERNAL_ERROR] A method named "invoke" is not declared in any enclosing class nor any supertype
   	at org.apache.spark.SparkException$.internalError(SparkException.scala:77)
   	at org.apache.spark.SparkException$.internalError(SparkException.scala:81)
   	at org.apache.spark.sql.errors.QueryExecutionErrors$.methodNotDeclaredError(QueryExecutionErrors.scala:452)
   	at org.apache.spark.sql.catalyst.expressions.objects.InvokeLike.findMethod(objects.scala:173)
   	at org.apache.spark.sql.catalyst.expressions.objects.InvokeLike.findMethod$(objects.scala:170)
   	at org.apache.spark.sql.catalyst.expressions.objects.Invoke.findMethod(objects.scala:363)
   	at org.apache.spark.sql.catalyst.expressions.objects.Invoke.method$lzycompute(objects.scala:391)
   	at org.apache.spark.sql.catalyst.expressions.objects.Invoke.method(objects.scala:389)
   	at org.apache.spark.sql.catalyst.expressions.objects.Invoke.eval(objects.scala:401)
   	at org.apache.spark.sql.catalyst.expressions.HashExpression.eval(hash.scala:292)
   	at org.apache.spark.sql.catalyst.expressions.Pmod.eval(arithmetic.scala:1054)
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   Yes, Spark returns a more clear error message.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   Add UT.


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] pan3793 commented on a diff in pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #42128:
URL: https://github.com/apache/spark/pull/42128#discussion_r1273056929


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ObjectExpressionsSuite.scala:
##########
@@ -73,6 +73,32 @@ class ObjectExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
     checkEvaluationWithMutableProjection(invoke, null, inputRow)
   }
 
+  test("SPARK-44525: Invoke could not find method") {
+    val inputRow = InternalRow(new Object)
+    val inputObject = BoundReference(0, ObjectType(classOf[Object]), nullable = false)
+
+    val e1 = intercept[SparkException] {
+      Invoke(inputObject, "zeroArgNotExistMethod", IntegerType).eval(inputRow)
+    }
+
+    assert(e1.getErrorClass == "INTERNAL_ERROR")
+    assert(e1.getMessage == "[INTERNAL_ERROR] Couldn't find method zeroArgNotExistMethod " +
+      "with arguments () on class java.lang.Object.")
+
+    val e2 = intercept[SparkException] {
+      Invoke(
+        inputObject,
+        "oneArgNotExistMethod",
+        IntegerType,
+        Seq(Literal.fromObject(UTF8String.fromString("dummyInputString"))),
+        Seq(StringType)).eval(inputRow)
+    }
+
+    assert(e2.getErrorClass == "INTERNAL_ERROR")

Review Comment:
   thought, but it seems does not support verifying the message



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] LuciferYang commented on pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #42128:
URL: https://github.com/apache/spark/pull/42128#issuecomment-1651230999

   Merged into master 3.5. Thanks @ulysses-you and @pan3793 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] pan3793 commented on a diff in pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #42128:
URL: https://github.com/apache/spark/pull/42128#discussion_r1273038881


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -465,6 +465,20 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase {
       s"""A method named "$name" is not declared in any enclosing class nor any supertype""")
   }
 
+  def methodNotFoundError(

Review Comment:
   updated



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] LuciferYang commented on a diff in pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #42128:
URL: https://github.com/apache/spark/pull/42128#discussion_r1273055437


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ObjectExpressionsSuite.scala:
##########
@@ -73,6 +73,32 @@ class ObjectExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
     checkEvaluationWithMutableProjection(invoke, null, inputRow)
   }
 
+  test("SPARK-44525: Invoke could not find method") {
+    val inputRow = InternalRow(new Object)
+    val inputObject = BoundReference(0, ObjectType(classOf[Object]), nullable = false)
+
+    val e1 = intercept[SparkException] {
+      Invoke(inputObject, "zeroArgNotExistMethod", IntegerType).eval(inputRow)
+    }
+
+    assert(e1.getErrorClass == "INTERNAL_ERROR")
+    assert(e1.getMessage == "[INTERNAL_ERROR] Couldn't find method zeroArgNotExistMethod " +
+      "with arguments () on class java.lang.Object.")
+
+    val e2 = intercept[SparkException] {
+      Invoke(
+        inputObject,
+        "oneArgNotExistMethod",
+        IntegerType,
+        Seq(Literal.fromObject(UTF8String.fromString("dummyInputString"))),
+        Seq(StringType)).eval(inputRow)
+    }
+
+    assert(e2.getErrorClass == "INTERNAL_ERROR")

Review Comment:
   hmm.. suggest using `SparkFunSuite#checkError` to assert
   
   
   
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] pan3793 commented on a diff in pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #42128:
URL: https://github.com/apache/spark/pull/42128#discussion_r1272962703


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -465,6 +465,20 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase {
       s"""A method named "$name" is not declared in any enclosing class nor any supertype""")
   }
 
+  def methodNotFoundError(

Review Comment:
   I searched the codebase, seems `Invoke` `StaticInvoke` is only used internally, let me convert it to `internalError` as you suggested.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] pan3793 commented on pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #42128:
URL: https://github.com/apache/spark/pull/42128#issuecomment-1648843073

   cc @HyukjinKwon @yaooqinn @LuciferYang


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] pan3793 commented on a diff in pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #42128:
URL: https://github.com/apache/spark/pull/42128#discussion_r1273056929


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ObjectExpressionsSuite.scala:
##########
@@ -73,6 +73,32 @@ class ObjectExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
     checkEvaluationWithMutableProjection(invoke, null, inputRow)
   }
 
+  test("SPARK-44525: Invoke could not find method") {
+    val inputRow = InternalRow(new Object)
+    val inputObject = BoundReference(0, ObjectType(classOf[Object]), nullable = false)
+
+    val e1 = intercept[SparkException] {
+      Invoke(inputObject, "zeroArgNotExistMethod", IntegerType).eval(inputRow)
+    }
+
+    assert(e1.getErrorClass == "INTERNAL_ERROR")
+    assert(e1.getMessage == "[INTERNAL_ERROR] Couldn't find method zeroArgNotExistMethod " +
+      "with arguments () on class java.lang.Object.")
+
+    val e2 = intercept[SparkException] {
+      Invoke(
+        inputObject,
+        "oneArgNotExistMethod",
+        IntegerType,
+        Seq(Literal.fromObject(UTF8String.fromString("dummyInputString"))),
+        Seq(StringType)).eval(inputRow)
+    }
+
+    assert(e2.getErrorClass == "INTERNAL_ERROR")

Review Comment:
   ~~thought, but it seems does not support verifying the message~~



##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ObjectExpressionsSuite.scala:
##########
@@ -73,6 +73,32 @@ class ObjectExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
     checkEvaluationWithMutableProjection(invoke, null, inputRow)
   }
 
+  test("SPARK-44525: Invoke could not find method") {
+    val inputRow = InternalRow(new Object)
+    val inputObject = BoundReference(0, ObjectType(classOf[Object]), nullable = false)
+
+    val e1 = intercept[SparkException] {
+      Invoke(inputObject, "zeroArgNotExistMethod", IntegerType).eval(inputRow)
+    }
+
+    assert(e1.getErrorClass == "INTERNAL_ERROR")
+    assert(e1.getMessage == "[INTERNAL_ERROR] Couldn't find method zeroArgNotExistMethod " +
+      "with arguments () on class java.lang.Object.")
+
+    val e2 = intercept[SparkException] {
+      Invoke(
+        inputObject,
+        "oneArgNotExistMethod",
+        IntegerType,
+        Seq(Literal.fromObject(UTF8String.fromString("dummyInputString"))),
+        Seq(StringType)).eval(inputRow)
+    }
+
+    assert(e2.getErrorClass == "INTERNAL_ERROR")

Review Comment:
   Thanks, updated



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] LuciferYang commented on a diff in pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #42128:
URL: https://github.com/apache/spark/pull/42128#discussion_r1272955689


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -465,6 +465,20 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase {
       s"""A method named "$name" is not declared in any enclosing class nor any supertype""")
   }
 
+  def methodNotFoundError(

Review Comment:
   this was defined as `internalError` previously, really need to add a new `errorClass`?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] pan3793 commented on pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #42128:
URL: https://github.com/apache/spark/pull/42128#issuecomment-1651255984

   Thanks @LuciferYang and @ulysses-you 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] LuciferYang closed pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang closed pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found
URL: https://github.com/apache/spark/pull/42128


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] pan3793 commented on pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #42128:
URL: https://github.com/apache/spark/pull/42128#issuecomment-1650876035

   Emm... seems the test passed but reported failure? https://github.com/pan3793/spark/actions/runs/5653530123


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] LuciferYang commented on a diff in pull request #42128: [SPARK-44525][SQL] Improve error message when Invoke method is not found

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #42128:
URL: https://github.com/apache/spark/pull/42128#discussion_r1273055437


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ObjectExpressionsSuite.scala:
##########
@@ -73,6 +73,32 @@ class ObjectExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
     checkEvaluationWithMutableProjection(invoke, null, inputRow)
   }
 
+  test("SPARK-44525: Invoke could not find method") {
+    val inputRow = InternalRow(new Object)
+    val inputObject = BoundReference(0, ObjectType(classOf[Object]), nullable = false)
+
+    val e1 = intercept[SparkException] {
+      Invoke(inputObject, "zeroArgNotExistMethod", IntegerType).eval(inputRow)
+    }
+
+    assert(e1.getErrorClass == "INTERNAL_ERROR")
+    assert(e1.getMessage == "[INTERNAL_ERROR] Couldn't find method zeroArgNotExistMethod " +
+      "with arguments () on class java.lang.Object.")
+
+    val e2 = intercept[SparkException] {
+      Invoke(
+        inputObject,
+        "oneArgNotExistMethod",
+        IntegerType,
+        Seq(Literal.fromObject(UTF8String.fromString("dummyInputString"))),
+        Seq(StringType)).eval(inputRow)
+    }
+
+    assert(e2.getErrorClass == "INTERNAL_ERROR")

Review Comment:
   hmm.. should we change to use `SparkFunSuite#checkError` ?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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