Skip to content
Snippets Groups Projects
Commit 2154345b authored by Dongjoon Hyun's avatar Dongjoon Hyun Committed by Sean Owen
Browse files

[SPARK-16940][SQL] `checkAnswer` should raise `TestFailedException` for wrong results

## What changes were proposed in this pull request?

This PR fixes the following to make `checkAnswer` raise `TestFailedException` again instead of `java.util.NoSuchElementException: key not found: TZ` in the environments without `TZ` variable. Also, this PR adds `QueryTestSuite` class for testing `QueryTest` itself.

```scala
- |Timezone Env: ${sys.env("TZ")}
+ |Timezone Env: ${sys.env.getOrElse("TZ", "")}
```

## How was this patch tested?

Pass the Jenkins tests with a new test suite.

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes #14528 from dongjoon-hyun/SPARK-16940.
parent af710e5b
No related branches found
No related tags found
No related merge requests found
......@@ -402,7 +402,7 @@ object QueryTest {
s"""
|Results do not match for query:
|Timezone: ${TimeZone.getDefault}
|Timezone Env: ${sys.env("TZ")}
|Timezone Env: ${sys.env.getOrElse("TZ", "")}
|
|${df.queryExecution}
|== Results ==
......@@ -483,3 +483,11 @@ object QueryTest {
}
}
}
class QueryTestSuite extends QueryTest with test.SharedSQLContext {
test("SPARK-16940: checkAnswer should raise TestFailedException for wrong results") {
intercept[org.scalatest.exceptions.TestFailedException] {
checkAnswer(sql("SELECT 1"), Row(2) :: Nil)
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment