Repository: spark Updated Branches: refs/heads/master e256392a1 -> 02c5325b8
[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 <[email protected]> Closes #15789 from dongjoon-hyun/SPARK-18292. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/02c5325b Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/02c5325b Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/02c5325b Branch: refs/heads/master Commit: 02c5325b8ff75bf2e5bcb66e0482298ab408b091 Parents: e256392 Author: Dongjoon Hyun <[email protected]> Authored: Wed Nov 9 17:48:16 2016 +0000 Committer: Sean Owen <[email protected]> Committed: Wed Nov 9 17:48:16 2016 +0000 ---------------------------------------------------------------------- .../apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/02c5325b/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala ---------------------------------------------------------------------- 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 12d18dc..8696337 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() --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
