CurtHagenlocher commented on code in PR #2692:
URL: https://github.com/apache/arrow-adbc/pull/2692#discussion_r2051045607


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -86,9 +100,70 @@ protected override TOpenSessionReq CreateSessionRequest()
                 Client_protocol_i64 = 
(long)TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V7,
                 CanUseMultipleCatalogs = true,
             };
+
+            // If not using queries to set server-side properties, include 
them in Configuration
+            if (!_applySSPWithQueries)
+            {
+                req.Configuration = new Dictionary<string, string>();
+                var serverSideProperties = GetServerSideProperties();
+                foreach (var property in serverSideProperties)
+                {
+                    req.Configuration[property.Key] = property.Value;
+                }
+            }
             return req;
         }
 
+        /// <summary>
+        /// Gets a dictionary of server-side properties extracted from 
connection properties.
+        /// </summary>
+        /// <returns>Dictionary of server-side properties with prefix removed 
from keys.</returns>
+        private Dictionary<string, string> GetServerSideProperties()
+        {
+            return Properties
+                .Where(p => 
p.Key.StartsWith(DatabricksParameters.ServerSidePropertyPrefix))
+                .ToDictionary(
+                    p => 
p.Key.Substring(DatabricksParameters.ServerSidePropertyPrefix.Length),
+                    p => p.Value
+                );
+        }
+
+        /// <summary>
+        /// Applies server-side properties by executing "set key=value" 
queries.
+        /// </summary>
+        /// <returns>A task representing the asynchronous operation.</returns>
+        public async Task ApplyServerSidePropertiesAsync()
+        {
+            if (!_applySSPWithQueries)
+            {
+                return;
+            }
+
+            var serverSideProperties = GetServerSideProperties();
+
+            if (serverSideProperties.Count == 0)
+            {
+                return;
+            }
+
+            using var statement = new DatabricksStatement(this);
+
+            foreach (var property in serverSideProperties)
+            {
+                string query = $"SET {property.Key}={property.Value}";

Review Comment:
   Hmm... okay, I tried it against Fabric Spark because I didn't have any 
Databricks test credentials handy and it seems to work there so I guess the 
Spark SQL parser is generally fine with it.



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to