Skip to content

Commit

Permalink
[SPARK-47179][SQL] Improve error message from SparkThrowableSuite for…
Browse files Browse the repository at this point in the history
… 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 apache#45273 from itholic/improve_error_suite_debuggability.

Authored-by: Haejoon Lee <haejoon.lee@databricks.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>
  • Loading branch information
itholic authored and TakawaAkirayo committed Mar 4, 2024
1 parent 01e361a commit cac5094
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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`")
}
})

Expand All @@ -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()
Expand All @@ -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`")
}
}

Expand Down

0 comments on commit cac5094

Please sign in to comment.