-
Notifications
You must be signed in to change notification settings - Fork 28k
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
[MINOR][SQL] Use resource path for test_script.sh #15246
Conversation
Test build #65933 has finished for PR 15246 at commit
|
Hm, I see why this happens to work, because the file is not packaged inside a jar file. Normally that's what getResource is for, and if it were in a jar this wouldn't work. It's not a bad idea though isn't it easier to just set the working dir for the project in your IDE? IJ can do that. |
Hi, @srowen Thanks a lot for the comments. Yes, setting the working dir can work. However, working dir varies from machine to machine. It would be a little tricky to maintain and troubleshoot in the future. Configuration settings of IDE is not managed and version controlled now. So I think it will be better to make the test case independent with the IDE settings. |
It's a fair point, though I'm also wondering -- aren't there many other instances of this throughout the tests? in some cases the file would happen to get put on a classpath by the IDE but not always. Is it possible to fix more, or all such issues the same way? |
Hi, @srowen Yes, you are right. I am searching the code base to see if we can fix more. |
I have searched |
Test build #66300 has finished for PR 15246 at commit
|
Hi, @srowen Could you please review this again? Thanks. |
I wonder if you could make a utility method for this in I suppose it's fine to assume that whatever is in |
Hi, @srowen Thanks for the suggestion. Yes, I have updated the PR to add utility methods for this in SparkFunSuite and include |
Test build #66337 has finished for PR 15246 at commit
|
At commit 2ea3eea, it reverted the changes in |
Test build #66344 has finished for PR 15246 at commit
|
Not sure why |
The changes should be safe to |
Retest this please. |
Hi, @srowen Could you please re-trigger jenkins to retest this? I think the the failure of |
Jenkins add to whitelist |
Jenkins retest this please |
Test build #66390 has finished for PR 15246 at commit
|
|
@@ -41,6 +43,15 @@ abstract class SparkFunSuite | |||
} | |||
} | |||
|
|||
// helper function | |||
protected final def getFile(file: String): File = { |
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 like what you've done here with getCanonicalPath
. Does this call here need getCanonicalFile
for good measure? I supposes there's also something like Paths.get(... toURI).toFile
but I don't know if that acts any differently.
How about calling these getTestResourceFile
and getTestResourcePath
?
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.
@srowen getTestResourceFile and getTestResourcePath look better. Thanks.
URL class doesn't have a method like getCanonicalFile. It has getFile only.
Also, I tested Paths.get(... toURI).toFile. The only difference I noticed is that it keeps spaces as usual, but getFile(file).getCanonicalPath converts spaces to "%20". I suppose they are both OK.
@@ -17,6 +17,7 @@ | |||
|
|||
package org.apache.spark.sql.hive.execution | |||
|
|||
import java.io.File |
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.
Is this used? maybe I'm missing it
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.
No. Will delete it.
if (testCommandAvailable("bash") && testCommandAvailable("echo | sed")) { | ||
val df = Seq(("x1", "y1", "z1"), ("x2", "y2", "z2")).toDF("c1", "c2", "c3") | ||
df.createOrReplaceTempView("script_table") | ||
val query1 = sql( | ||
""" | ||
s""" |
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 was wondering whether string interpolation and triple quotes work together, and I think they do except for some odd corner cases: http://stackoverflow.com/questions/25632924/whats-the-difference-between-raw-string-interpolation-and-triple-quotes-in-scal It's probably OK here but made me double-check.
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.
Yes. Good catch. There are some odd corner cases for s""" """
, but it should be OK here.
Test build #66482 has finished for PR 15246 at commit
|
Hi, @srowen all tests passed this time. Could you please review this PR again? Thanks. |
Thank you for approving, @srowen |
Merged to master |
## What changes were proposed in this pull request? This PR modified the test case `test("script")` to use resource path for `test_script.sh`. Make the test case portable (even in IntelliJ). ## How was this patch tested? Passed the test case. Before: Run `test("script")` in IntelliJ: ``` Caused by: org.apache.spark.SparkException: Subprocess exited with status 127. Error: bash: src/test/resources/test_script.sh: No such file or directory ``` After: Test passed. Author: Weiqing Yang <yangweiqing001@gmail.com> Closes apache#15246 from weiqingy/hivetest.
What changes were proposed in this pull request?
This PR modified the test case
test("script")
to use resource path fortest_script.sh
. Make the test case portable (even in IntelliJ).How was this patch tested?
Passed the test case.
Before:
Run
test("script")
in IntelliJ:After:
Test passed.