Skip to content

Commit

Permalink
[SPARK-18292][SQL] LogicalPlanToSQLSuite should not use resource depe…
Browse files Browse the repository at this point in the history
…ndent 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.

(cherry picked from commit 02c5325)
Signed-off-by: Sean Owen <sowen@cloudera.com>
  • Loading branch information
dongjoon-hyun authored and srowen committed Nov 9, 2016
1 parent b89c38b commit ac441d1
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ac441d1

Please sign in to comment.