CurtHagenlocher commented on code in PR #2896:
URL: https://github.com/apache/arrow-adbc/pull/2896#discussion_r2122310327
##########
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) {
Review Comment:
nit: move opening brace to new line
##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -374,6 +370,31 @@ protected override TOpenSessionReq CreateSessionRequest()
return req;
}
+
+ protected override async Task
HandleOpenSessionResponse(TOpenSessionResp? session)
+ {
+ await base.HandleOpenSessionResponse(session);
+ if (session != null)
+ {
+ _enableMultipleCatalogSupport =
session.__isset.canUseMultipleCatalogs ? session.CanUseMultipleCatalogs : false;
+ 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) {
Review Comment:
nit: move opening brace to new line
##########
csharp/src/Drivers/Databricks/readme.md:
##########
@@ -38,7 +38,7 @@ The Databricks ADBC driver supports the following
authentication methods:
Basic (username and password) authentication is not supported at this time.
-Optional default catalog and default schema can be set for the session with
`adbc.connection.catalog` and `adbc.connection.db_schema` (catalog must be set
if default schema is provided).
+Optional default catalog and default schema can be set for the session with
`adbc.connection.catalog` and `adbc.connection.db_schema`. The default catalog
and schema will be used for subsequent metadata calls unless user specified
different catalog/schema to use.
Review Comment:
nit: consider wrapping onto a second line
##########
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 the identifier here be escaped?
It's my vague understanding that the behavior of USE depends on whether or
not there is a current catalog. Will there always be one when we get here or is
my understanding wrong?
--
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]