From 4baa36bb29d731d4215b533a1d55ff5c3a494032 Mon Sep 17 00:00:00 2001 From: Dongjoon Hyun Date: Mon, 30 Jun 2025 18:53:51 -0700 Subject: [PATCH] [SPARK-52627] Improve `SQLTests` to handle `userName` --- .../Resources/queries/describe_database.sql.answer | 2 +- Tests/SparkConnectTests/SQLTests.swift | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Tests/SparkConnectTests/Resources/queries/describe_database.sql.answer b/Tests/SparkConnectTests/Resources/queries/describe_database.sql.answer index 28c7c7d..c699c94 100644 --- a/Tests/SparkConnectTests/Resources/queries/describe_database.sql.answer +++ b/Tests/SparkConnectTests/Resources/queries/describe_database.sql.answer @@ -5,5 +5,5 @@ |Namespace Name| default| | Comment| default database| | Location|*| -| Owner| *| +| Owner| spark| +--------------+----------------------------------------+ \ No newline at end of file diff --git a/Tests/SparkConnectTests/SQLTests.swift b/Tests/SparkConnectTests/SQLTests.swift index 808c27b..bd9207b 100644 --- a/Tests/SparkConnectTests/SQLTests.swift +++ b/Tests/SparkConnectTests/SQLTests.swift @@ -36,7 +36,7 @@ struct SQLTests { let regexOwner = /(runner|185)/ private func cleanUp(_ str: String) -> String { - return removeOwner(removeID(removeLocation(str))) + return removeOwner(removeID(removeLocation(replaceUserName(str)))) } private func removeID(_ str: String) -> String { @@ -51,6 +51,14 @@ struct SQLTests { return str.replacing(regexOwner, with: "*") } + private func replaceUserName(_ str: String) -> String { + #if os(macOS) || os(Linux) + return str.replacing(ProcessInfo.processInfo.userName, with: "spark") + #else + return str + #endif + } + private func normalize(_ str: String) -> String { return str.replacing(/[-]+/, with: "-").replacing(/[ ]+/, with: " ") }