Skip to content

Commit

Permalink
[MINOR][TEST] Add output/exception to error message when schema not m…
Browse files Browse the repository at this point in the history
…atched in `TPCDSQueryTestSuite`

### What changes were proposed in this pull request?

This patch adds output/exception string to the error message when output schema not match expected schema in `TPCDSQueryTestSuite`.

### Why are the changes needed?

We have used `TPCDSQueryTestSuite` for testing TPCDS query results. The test suite checks output schema and then output result. If any exception happens during query execution, it will handle the exception and return an empty schema and exception class + message as output. So, when any exception happens, the test suite just fails on schema check and never uses/shows the exception, e.g.,

```
java.lang.Exception: Expected "struct<[count(1):bigint]>", but got "struct<[]>" Schema did not match
```

We cannot see what exception was happened there from the log. It is somehow inconvenient for debugging.

### Does this PR introduce _any_ user-facing change?

No, test only.

### How was this patch tested?

Existing tests

### Was this patch authored or co-authored using generative AI tooling?

No

Closes apache#45025 from viirya/minor_ouput_exception.

Authored-by: Liang-Chi Hsieh <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
  • Loading branch information
viirya authored and dongjoon-hyun committed Feb 5, 2024
1 parent 6ff5f39 commit e969713
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ class TPCDSQueryTestSuite extends QueryTest with TPCDSBase with SQLQueryTestHelp
(segments(1).trim, segments(2).replaceAll("\\s+$", ""))
}

assertResult(expectedSchema, s"Schema did not match\n$queryString") {
val notMatchedSchemaOutput = if (schema == emptySchema) {
// There might be exception. See `handleExceptions`.
s"Schema did not match\n$queryString\nOutput/Exception: $outputString"
} else {
s"Schema did not match\n$queryString"
}

assertResult(expectedSchema, notMatchedSchemaOutput) {
schema
}
if (shouldSortResults) {
Expand Down

0 comments on commit e969713

Please sign in to comment.