New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-18292][SQL] LogicalPlanToSQLSuite should not use resource dependent path for golden file generation #15789
Conversation
…ndent path for golden file generation
Hi, @gatorsmile . |
Test build #68233 has finished for PR 15789 at commit
|
Oh, you mean the the following. I'll fix this PR again. Sorry, @gatorsmile . private val baseResourcePath = {
// 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", "sql-tests").toFile
} else {
val res = getClass.getClassLoader.getResource("sql-tests")
new File(res.getFile)
}
} |
Retest this please |
It's fixed like |
Retest this please. |
Test build #68232 has finished for PR 15789 at commit
|
There occurs four
|
Retest this please |
Test build #68237 has finished for PR 15789 at commit
|
// 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I see. This seems OK. I think it's OK to just do new File("src/test/resources/sqlgen")
here instead, since that's what other tests do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to confirm that you already tested it in your private branch, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked that. But, to make it sure, I'll check it again right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. I tested this in my private branch in a separate folder. When I changed the query for range
, the output file is changed like the following.
SPARK-18292-SQLGEN:SPARK-18292$ pwd
/Users/dhyun/SPARK-18292-SQLGEN
SPARK-18292-SQLGEN:SPARK-18292$ git branch
* SPARK-18292
master
SPARK-18292-SQLGEN:SPARK-18292$ pwd
/Users/dhyun/SPARK-18292-SQLGEN
SPARK-18292-SQLGEN:SPARK-18292$ git status
On branch SPARK-18292
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: sql/hive/src/test/resources/sqlgen/range.sql
modified: sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala
LGTM except a comment. |
Thank you, @srowen and @gatorsmile . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh OK, let's leave it then.
Thank you, @srowen ! |
Can you explain what the actual issue is? I read the description and still have no idea. |
Hi, @rxin . Yep. The actual issue is the current code generates the new golden files in the following folder. So, we cannot identify which file is changed and cannot commit the newly generated files easily.
When we added this module initially, we faced the exactly same issue and decided to use the absolute path and to assume the following command in the source tree root.
|
I'll merge if there are no further comments. To restate -- basically the test helper function returns a path that is perfectly fine for reading test data, and is flexible because it doesn't depend on what the current working dir is. However it won't work as a location to write to, which is only rarely ever needed like in cases like this. |
Thank you, @srowen ! |
Merged to master/2.1 |
…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>
Thank you for review and merging, @srowen , @gatorsmile , and @rxin . |
…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 apache#15789 from dongjoon-hyun/SPARK-18292.
What changes were proposed in this pull request?
LogicalPlanToSQLSuite
uses the following command to update the existing answer files.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.