-
Notifications
You must be signed in to change notification settings - Fork 173
feat(csharp/src/Drivers/Databricks): Multiple catalogs with default database #2921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(csharp/src/Drivers/Databricks): Multiple catalogs with default database #2921
Conversation
50ae107 to
7c511cd
Compare
9b86054 to
d28726c
Compare
| Properties.TryGetValue(AdbcOptions.Connection.CurrentDbSchema, out defaultSchema); | ||
|
|
||
| // SPARK is a special catalog name - rely on server to return a default catalog if there is one | ||
| if (defaultCatalog.Equals("SPARK", StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you reuse this:
| private void HandleSparkCatalog() |
300f0d0 to
c415169
Compare
| { | ||
| SchemaName = defaultNamespace.SchemaName; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since ODBC does not use schema for subsequent queries, removing it here to be consistent
| Properties.TryGetValue(AdbcOptions.Connection.CurrentDbSchema, out defaultSchema); | ||
|
|
||
| // SPARK is a special catalog name - rely on server to return a default catalog if there is one | ||
| defaultCatalog = HandleSparkCatalog(defaultCatalog); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: How would some use pass in SPARK as initial catalog? They are passing SPARK in PowerBI UI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this question-and-answer. Someone can pass SPARK as the initial catalog but then it gets ignored? And this is the correct behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This maintains backward compatibility with older workspaces, where the Hive metastore was accessed via the spark catalog name.
In newer DBR versions with Unity Catalog, the default catalog is typically hive_metastore.
Passing null here allows the runtime to fall back to the workspace-defined default catalog for the session.
Let me add a comment to be clearer. Does the above make sense?
| if (CatalogName == null) | ||
| if (CatalogName == null && connection.EnableMultipleCatalogSupport) | ||
| { | ||
| CatalogName = defaultNamespace.CatalogName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I realize that for GetCrossReference, it has a CatalogName and ForeignCatalog name, in our case where we will only assign foreign catalog/schema/table to the call, and in those case the catalogName is null and we should not override.
I've tested it, it seems working fine even we assign the catalogName where the actual parentTable is in another catalog. Let's add a TODO here just noting that.
CurtHagenlocher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I have one question and one nitpick.
| } | ||
| } | ||
|
|
||
| internal static String? HandleSparkCatalog(String? CatalogName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| internal static String? HandleSparkCatalog(String? CatalogName) | |
| internal static string? HandleSparkCatalog(string? catalogName) |
That is, use the type alias string instead of the type name String and use a lower-case argument name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good catch thanks!
| Properties.TryGetValue(AdbcOptions.Connection.CurrentDbSchema, out defaultSchema); | ||
|
|
||
| // SPARK is a special catalog name - rely on server to return a default catalog if there is one | ||
| defaultCatalog = HandleSparkCatalog(defaultCatalog); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this question-and-answer. Someone can pass SPARK as the initial catalog but then it gets ignored? And this is the correct behavior?
refactor refactor test more fixes todo comment
c8ea6e6 to
3bf027d
Compare
Changes
This PR makes changes to be consistent with odbc behavior
ODBC behavior:
ODBC does the following when
EnableMultipleCatalogsSupport=0ODBC Driver Behavior Testing
GetColumns(null, null, null, null)
GetColumns(x, null, null, null)
GetColumns(null, null, null, null)
GetColumns(hive_metastore, null, null, null)
GetColumns(null, null, null, null)
GetColumns(x, null, null, null)
GetColumns(null, null, null, null)
GetColumns(hive_metastore, null, null, null)
GetColumns(null, null, null, null)
GetColumns(hive_metastore, null, null, null)
Testing
Adds an extensive grid test to validate different edge cases during creation
TODO