Skip to content

Commit faae9a3

Browse files
committed
[SPARK-51864] Rename parameters and support case-insensitively
### What changes were proposed in this pull request? This PR aims to rename parameters and support it case-insensitively according to the documentation. - https://github.com/apache/spark/blob/master/sql/connect/docs/client-connection-string.md ### Why are the changes needed? To match with the documentation. ### Does this PR introduce _any_ user-facing change? No, this is a change on the unreleased version. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #81 from dongjoon-hyun/SPARK-51864. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 129cb59 commit faae9a3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Sources/SparkConnect/SparkConnectClient.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public actor SparkConnectClient {
4949
#endif
5050
for param in self.url.path.split(separator: ";").dropFirst().filter({ !$0.isEmpty }) {
5151
let kv = param.split(separator: "=")
52-
switch String(kv[0]) {
52+
switch String(kv[0]).lowercased() {
5353
case URIParams.PARAM_USER_AGENT:
5454
clientType = String(kv[1])
5555
case URIParams.PARAM_TOKEN:
@@ -618,11 +618,11 @@ public actor SparkConnectClient {
618618
}
619619

620620
private enum URIParams {
621-
static let PARAM_USER_ID = "userId"
622-
static let PARAM_USER_AGENT = "userAgent"
621+
static let PARAM_GRPC_MAX_MESSAGE_SIZE = "grpc_max_message_size"
622+
static let PARAM_SESSION_ID = "session_id"
623623
static let PARAM_TOKEN = "token"
624-
static let PARAM_USE_SSL = "useSsl"
625-
static let PARAM_SESSION_ID = "sessionId"
626-
static let PARAM_GRPC_MAX_MESSAGE_SIZE = "grpcMaxMessageSize"
624+
static let PARAM_USER_AGENT = "user_agent"
625+
static let PARAM_USER_ID = "user_id"
626+
static let PARAM_USE_SSL = "use_ssl"
627627
}
628628
}

Tests/SparkConnectTests/SparkConnectClientTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct SparkConnectClientTests {
3535

3636
@Test
3737
func parameters() async throws {
38-
let client = SparkConnectClient(remote: "sc://host1:123/;token=abcd;userId=test;userAgent=myagent")
38+
let client = SparkConnectClient(remote: "sc://host1:123/;tOkeN=abcd;user_ID=test;USER_agent=myagent")
3939
#expect(await client.token == "abcd")
4040
#expect(await client.userContext.userID == "test")
4141
#expect(await client.clientType == "myagent")

0 commit comments

Comments
 (0)