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 <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
  • Loading branch information
itholic authored and MaxGekk committed Feb 27, 2024
1 parent cdae4c6 commit 9d2fd5e
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 9d2fd5e

Please sign in to comment.