Skip to content

Commit bfa92ae

Browse files
committed
[SPARK-52627] Improve SQLTests to handle userName
### What changes were proposed in this pull request? This PR aims to improve `SQLTests` to handle `userName` additionally. ### Why are the changes needed? This is helpful in case of running `Spark Connect Server` without docker images. For example, when building and running from the source instead of Docker image. ### Does this PR introduce _any_ user-facing change? No behavior change. ### How was this patch tested? Pass the CIs. **Build and run from the source** ``` $ build/sbt package $ cd sbin/ $ SPARK_NO_DAEMONIZE=1 ./start-connect-server.sh ``` **Test** ``` $ swift test --filter SQLTests ... ✔ Test runAll() passed after 2.719 seconds. ✔ Suite SQLTests passed after 2.723 seconds. ✔ Test run with 5 tests passed after 2.723 seconds. ``` ### Was this patch authored or co-authored using generative AI tooling? No. Closes #203 from dongjoon-hyun/removeOwner. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent fc90ae5 commit bfa92ae

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Tests/SparkConnectTests/Resources/queries/describe_database.sql.answer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
|Namespace Name| default|
66
| Comment| default database|
77
| Location|*|
8-
| Owner| *|
8+
| Owner| spark|
99
+--------------+----------------------------------------+

Tests/SparkConnectTests/SQLTests.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct SQLTests {
3636
let regexOwner = /(runner|185)/
3737

3838
private func cleanUp(_ str: String) -> String {
39-
return removeOwner(removeID(removeLocation(str)))
39+
return removeOwner(removeID(removeLocation(replaceUserName(str))))
4040
}
4141

4242
private func removeID(_ str: String) -> String {
@@ -51,6 +51,14 @@ struct SQLTests {
5151
return str.replacing(regexOwner, with: "*")
5252
}
5353

54+
private func replaceUserName(_ str: String) -> String {
55+
#if os(macOS) || os(Linux)
56+
return str.replacing(ProcessInfo.processInfo.userName, with: "spark")
57+
#else
58+
return str
59+
#endif
60+
}
61+
5462
private func normalize(_ str: String) -> String {
5563
return str.replacing(/[-]+/, with: "-").replacing(/[ ]+/, with: " ")
5664
}

0 commit comments

Comments
 (0)