diff options
author | Dongjoon Hyun <dongjoon@apache.org> | 2016-11-09 17:48:16 +0000 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-11-09 17:48:16 +0000 |
commit | 02c5325b8ff75bf2e5bcb66e0482298ab408b091 (patch) | |
tree | 1579c9b515c7ac0b7fc01976066cb9baa2b6760a | |
parent | e256392a128c8fffa8abb86ab99224ae09b0e1ff (diff) | |
download | spark-02c5325b8ff75bf2e5bcb66e0482298ab408b091.tar.gz spark-02c5325b8ff75bf2e5bcb66e0482298ab408b091.tar.bz2 spark-02c5325b8ff75bf2e5bcb66e0482298ab408b091.zip |
[SPARK-18292][SQL] LogicalPlanToSQLSuite should not use resource dependent path for golden file generation
## What changes were proposed in this pull request?
`LogicalPlanToSQLSuite` uses the following command to update the existing answer files.
```bash
SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "hive/test-only *LogicalPlanToSQLSuite"
```
However, after introducing `getTestResourcePath`, it fails to update the previous golden answer files in the predefined directory. This issue aims to fix that.
## How was this patch tested?
It's a testsuite update. Manual.
Author: Dongjoon Hyun <dongjoon@apache.org>
Closes #15789 from dongjoon-hyun/SPARK-18292.
-rw-r--r-- | sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala index 12d18dc87c..8696337b9d 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala @@ -46,7 +46,15 @@ class LogicalPlanToSQLSuite extends SQLBuilderTest with SQLTestUtils { // Used for generating new query answer files by saving private val regenerateGoldenFiles: Boolean = System.getenv("SPARK_GENERATE_GOLDEN_FILES") == "1" - private val goldenSQLPath = getTestResourcePath("sqlgen") + private val goldenSQLPath = { + // If regenerateGoldenFiles is true, we must be running this in SBT and we use hard-coded + // relative path. Otherwise, we use classloader's getResource to find the location. + if (regenerateGoldenFiles) { + java.nio.file.Paths.get("src", "test", "resources", "sqlgen").toFile.getCanonicalPath + } else { + getTestResourcePath("sqlgen") + } + } protected override def beforeAll(): Unit = { super.beforeAll() |