This is an automated email from the ASF dual-hosted git repository.
curth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 92ceccec5 fix(csharp/src/Drivers/Apache/Spark): fix parameter naming
convention (#1895)
92ceccec5 is described below
commit 92ceccec50ceb0d6987e3d97f71c124258dd17ff
Author: davidhcoe <[email protected]>
AuthorDate: Mon Jun 3 15:52:47 2024 -0400
fix(csharp/src/Drivers/Apache/Spark): fix parameter naming convention
(#1895)
- Adds the parameter naming convention to match other adbc projects
- Fixes the UserAgent name
---------
Co-authored-by: David Coe <[email protected]>
---
csharp/src/Drivers/Apache/Spark/SparkConnection.cs | 12 ++++-----
csharp/src/Drivers/Apache/Spark/SparkParameters.cs | 31 ++++++++++++++++++++++
csharp/test/Drivers/Apache/Spark/SparkTestBase.cs | 7 +++--
3 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/csharp/src/Drivers/Apache/Spark/SparkConnection.cs
b/csharp/src/Drivers/Apache/Spark/SparkConnection.cs
index c4a3a1b75..33a65f0a8 100644
--- a/csharp/src/Drivers/Apache/Spark/SparkConnection.cs
+++ b/csharp/src/Drivers/Apache/Spark/SparkConnection.cs
@@ -39,7 +39,7 @@ namespace Apache.Arrow.Adbc.Drivers.Apache.Spark
{
public class SparkConnection : HiveServer2Connection
{
- const string UserAgent = "MicrosoftSparkODBCDriver/2.7.6.1014";
+ private readonly string UserAgent = $"{InfoDriverName.Replace(" ",
"")}/{ProductVersionDefault}";
readonly AdbcInfoCode[] infoSupportedCodes = new[] {
AdbcInfoCode.DriverName,
@@ -271,14 +271,14 @@ namespace Apache.Arrow.Adbc.Drivers.Apache.Spark
Trace.TraceError($"key = {property} value =
{properties[property]}");
}
- string hostName = properties["hostname"];
- string path = properties["path"];
+ string hostName = properties[SparkParameters.HostName];
+ string path = properties[SparkParameters.Path];
string token;
- if (properties.ContainsKey("token"))
- token = properties["token"];
+ if (properties.ContainsKey(SparkParameters.Token))
+ token = properties[SparkParameters.Token];
else
- token = properties["password"];
+ token = properties[SparkParameters.Password];
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new UriBuilder(Uri.UriSchemeHttps,
hostName, -1, path).Uri;
diff --git a/csharp/src/Drivers/Apache/Spark/SparkParameters.cs
b/csharp/src/Drivers/Apache/Spark/SparkParameters.cs
new file mode 100644
index 000000000..4843d13b4
--- /dev/null
+++ b/csharp/src/Drivers/Apache/Spark/SparkParameters.cs
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Arrow.Adbc.Drivers.Apache.Spark
+{
+ /// <summary>
+ /// Parameters used for connecting to Spark data sources.
+ /// </summary>
+ public class SparkParameters
+ {
+ public const string HostName = "adbc.spark.host";
+ public const string Port = "adbc.spark.port";
+ public const string Path = "adbc.spark.path";
+ public const string Token = "adbc.spark.token";
+ public const string Password = "password";
+ }
+}
diff --git a/csharp/test/Drivers/Apache/Spark/SparkTestBase.cs
b/csharp/test/Drivers/Apache/Spark/SparkTestBase.cs
index 4a1482e47..faaf180bc 100644
--- a/csharp/test/Drivers/Apache/Spark/SparkTestBase.cs
+++ b/csharp/test/Drivers/Apache/Spark/SparkTestBase.cs
@@ -47,18 +47,17 @@ namespace Apache.Arrow.Adbc.Tests.Drivers.Apache.Spark
{
Dictionary<string, string> parameters =
new(StringComparer.OrdinalIgnoreCase);
- // TODO: make these parameters that are passed in
if (!string.IsNullOrEmpty(testConfiguration.HostName))
{
- parameters.Add("HostName", testConfiguration.HostName!);
+ parameters.Add(SparkParameters.HostName,
testConfiguration.HostName!);
}
if (!string.IsNullOrEmpty(testConfiguration.Path))
{
- parameters.Add("Path", testConfiguration.Path!);
+ parameters.Add(SparkParameters.Path, testConfiguration.Path!);
}
if (!string.IsNullOrEmpty(testConfiguration.Token))
{
- parameters.Add("Token", testConfiguration.Token!);
+ parameters.Add(SparkParameters.Token,
testConfiguration.Token!);
}
return parameters;