birschick-bq commented on code in PR #2352:
URL: https://github.com/apache/arrow-adbc/pull/2352#discussion_r1871773070
##########
csharp/src/Client/AdbcConnection.cs:
##########
@@ -237,7 +259,25 @@ private void SetConnectionProperties(string value)
object? builderValue = builder[key];
if (builderValue != null)
{
- this.adbcConnectionParameters.Add(key,
Convert.ToString(builderValue)!);
+ string paramValue = Convert.ToString(builderValue)!;
+
+ this.adbcConnectionParameters.Add(key, paramValue);
+
+ switch (key)
+ {
+ case ConnectionStringKeywords.DecimalBehavior:
+ this.DecimalBehavior =
(DecimalBehavior)Enum.Parse(typeof(DecimalBehavior), paramValue);
+ break;
+ case ConnectionStringKeywords.StructBehavior:
+ this.StructBehavior =
(StructBehavior)Enum.Parse(typeof(StructBehavior), paramValue);
+ break;
+ case ConnectionStringKeywords.CommandTimeout:
+ CommandTimeoutValue =
ConnectionStringParser.ParseTimeoutValue(paramValue);
+ break;
+ case ConnectionStringKeywords.ConnectionTimeout:
+ this.connectionTimeoutValue =
ConnectionStringParser.ParseTimeoutValue(paramValue);
Review Comment:
Since this has no effect on the underlying ADBC driver, is this to help
synchronize the value with the driver?
##########
csharp/src/Client/ConnectionStringParser.cs:
##########
@@ -0,0 +1,84 @@
+/*
+* 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.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Apache.Arrow.Adbc.Client
+{
+ internal class ConnectionStringKeywords
+ {
+ public const string ConnectionTimeout = "adbcconnectiontimeout";
+ public const string CommandTimeout = "adbccommandtimeout";
+ public const string StructBehavior = "structbehavior";
+ public const string DecimalBehavior = "decimalbehavior";
+ }
+
+ internal class ConnectionStringParser
+ {
+ public static TimeoutValue ParseTimeoutValue(string value)
+ {
+ string pattern = @"\(([^,]+),\s*([^,]+),\s*([^,]+)\)";
+
+ // Match the regex
+ Match match = Regex.Match(value, pattern);
+
+ if (match.Success)
+ {
+ string driverPropertyName = match.Groups[1].Value.Trim();
+ string timeoutAsString = match.Groups[2].Value.Trim();
+ string units = match.Groups[3].Value.Trim();
+
+ if (units != "s" && units != "ms")
+ {
+ throw new InvalidOperationException("invalid units");
+ }
+
+ TimeoutValue timeoutValue = new TimeoutValue
+ {
+ DriverPropertyName = driverPropertyName,
+ Value = int.Parse(timeoutAsString),
+ Units = units
+ };
+
+ return timeoutValue;
+ }
+ else
+ {
+ throw new InvalidOperationException("cannot parse the timeout
value");
Review Comment:
Maybe `ArgumentOutOfRangeException` instead of `InvalidOperationException`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]