eric-wang-1990 commented on code in PR #2896:
URL: https://github.com/apache/arrow-adbc/pull/2896#discussion_r2116745664


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -374,6 +370,27 @@ protected override TOpenSessionReq CreateSessionRequest()
             return req;
         }
 
+
+        protected override async Task 
HandleOpenSessionResponse(TOpenSessionResp? session)
+        {
+            await base.HandleOpenSessionResponse(session);
+            if (session != null)
+            {
+                if (session.__isset.initialNamespace) {
+                    _defaultNamespace = session.InitialNamespace;
+                } else if (_defaultNamespace != null && 
!string.IsNullOrEmpty(_defaultNamespace.SchemaName)) {
+                    // server version is too old. Explicitly set the schema 
using queries
+                    await SetSchema(_defaultNamespace.SchemaName);
+                }
+            }
+        }
+
+        private async Task SetSchema(string schemaName) {
+            using var statement = new DatabricksStatement(this);
+            statement.SqlQuery = $"USE {schemaName}";

Review Comment:
   Should this be use database xxx?



##########
csharp/src/Drivers/Databricks/DatabricksStatement.cs:
##########
@@ -41,6 +41,19 @@ internal class DatabricksStatement : SparkStatement, 
IHiveServer2Statement
         public DatabricksStatement(DatabricksConnection connection)
             : base(connection)
         {
+            // set the catalog name for legacy compatibility
+            // TODO: use catalog and schema fields in hiveserver2 connection 
instad of DefaultNamespace so we don't need to cast
+            var defaultNamespace = 
((DatabricksConnection)Connection).DefaultNamespace;
+            if (defaultNamespace != null) {
+                if (CatalogName == null)
+                {
+                    CatalogName = defaultNamespace.CatalogName;
+                }
+                if (SchemaName == null)
+                {
+                    SchemaName = defaultNamespace.SchemaName;

Review Comment:
   Is this expected? Does simba fill schema with default schema as well?



-- 
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