From cac509497d0b4e80276b9affa54155eb2b71093d Mon Sep 17 00:00:00 2001 From: Haejoon Lee Date: Tue, 27 Feb 2024 15:51:42 +0300 Subject: [PATCH] [SPARK-47179][SQL] Improve error message from SparkThrowableSuite for better debuggability ### What changes were proposed in this pull request? This PR proposes to improve error message from SparkThrowableSuite for better debuggability ### Why are the changes needed? The current error message is not very actionable for developer who need regenerating the error class documentation. ### Does this PR introduce _any_ user-facing change? No API change, but the error message is changed: **Before** ``` The error class document is not up to date. Please regenerate it. ``` **After** ``` he error class document is not up to date. Please regenerate it by running `SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "core/testOnly *SparkThrowableSuite -- -t \"Error classes match with document\""` ``` ### How was this patch tested? The existing CI should pass. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #45273 from itholic/improve_error_suite_debuggability. Authored-by: Haejoon Lee Signed-off-by: Max Gekk --- .../scala/org/apache/spark/SparkThrowableSuite.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala b/core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala index 1f3b28968025d..f41ad8fffd3e0 100644 --- a/core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala +++ b/core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala @@ -55,6 +55,9 @@ class SparkThrowableSuite extends SparkFunSuite { "core/testOnly *SparkThrowableSuite -- -t \"Error classes match with document\"" }}} */ + private val regenerateCommand = "SPARK_GENERATE_GOLDEN_FILES=1 build/sbt " + + "\"core/testOnly *SparkThrowableSuite -- -t \\\"Error classes match with document\\\"\"" + private val errorJsonFilePath = getWorkspaceFilePath( "common", "utils", "src", "main", "resources", "error", "error-classes.json") @@ -328,7 +331,8 @@ class SparkThrowableSuite extends SparkFunSuite { } } else { assert(subErrorDoc.trim == errorsInDoc.trim, - "The error class document is not up to date. Please regenerate it.") + "The error class document is not up to date. " + + s"Please regenerate it by running `$regenerateCommand`") } }) @@ -351,7 +355,8 @@ class SparkThrowableSuite extends SparkFunSuite { } } else { assert(sqlErrorParentDoc.trim == commonErrorsInDoc.trim, - "The error class document is not up to date. Please regenerate it.") + "The error class document is not up to date. " + + s"Please regenerate it by running `$regenerateCommand`") } val orphans = orphanedGoldenFiles() @@ -368,7 +373,8 @@ class SparkThrowableSuite extends SparkFunSuite { } } else { assert(orphans.isEmpty, - "Exist orphaned error class documents. Please regenerate it.") + "Exist orphaned error class documents. " + + s"Please regenerate it by running `$regenerateCommand`") } }