feat(csharp/src/Drivers/Databricks): Optimize GetColumnsExtendedAsync via DESC TABLE EXTENDED - #2953
Merged
Merged
Conversation
…xtended to implement GetColumnsExtendedAsync
jackyhu-db
force-pushed
the
desc-table-extended
branch
from
June 11, 2025 02:05
81b326f to
7d83b75
Compare
jackyhu-db
force-pushed
the
desc-table-extended
branch
from
June 11, 2025 04:36
49b3f6e to
8c73c0b
Compare
| * limitations under the License. | ||
| */ | ||
|
|
||
| using Apache.Arrow.Adbc.Drivers.Databricks.Result; |
Contributor
There was a problem hiding this comment.
Can we mocify/improve the existing GetColumnExtended tests to verify that:
With the flag on/off, they get same number of columns, same schema, and same data?
Contributor
Author
There was a problem hiding this comment.
I updated it to support test for both flag on/off as below, they are almost same except for the IS_NULLABLE on primary key.
[InlineData("all_column_types", "Resources/create_table_all_types.sql", "Resources/result_get_column_extended_all_types.json", true, new[] { "PK_IS_NULLABLE:NO" })]
[InlineData("all_column_types", "Resources/create_table_all_types.sql", "Resources/result_get_column_extended_all_types.json", false, new[] { "PK_IS_NULLABLE:YES" })]
public async Task CanGetColumnsExtended(string tableName,string createTableSqlLocation, string resultLocation, bool useDescTableExtended, string[] ?extraPlaceholdsInResult = null)
jackyhu-db
force-pushed
the
desc-table-extended
branch
2 times, most recently
from
June 12, 2025 03:53
4d4af63 to
4a0d05a
Compare
jackyhu-db
force-pushed
the
desc-table-extended
branch
from
June 12, 2025 04:19
4a0d05a to
bb93562
Compare
CurtHagenlocher
requested changes
Jun 19, 2025
CurtHagenlocher
left a comment
Contributor
There was a problem hiding this comment.
Thanks, looks good! I've just got a few nits about formatting and casing of method names.
jackyhu-db
force-pushed
the
desc-table-extended
branch
from
June 24, 2025 11:39
ba704ef to
aa7a763
Compare
CurtHagenlocher
requested changes
Jun 24, 2025
CurtHagenlocher
left a comment
Contributor
There was a problem hiding this comment.
Thanks! The changes look good but there's a merge conflict. Could you rebase on top of the latest sourced?
Contributor
Author
Done. |
CurtHagenlocher
approved these changes
Jun 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optimize GetColumnsExtendedAsync in Databricks via
DESC TABLE EXTENDEDMotivation
Currently,
HiveServer2Statement.GetColumnsExtendedAsyncwill make 3 thrift callsGetColumns,GetPrimaryKeysandGetCrossReferenceto get all the information and then join them into one result set. Now Databricks introduces a SQLDESC TABLE EXTENDED <table> AS JSONthat will return all of these information in one query, this can save 2 extra roundtrips and improve the performance.Description
Override
HiveServer2Statement.GetColumnsExtendedAsyncinDatabricksStatementby executing single SQLDESC TABLE EXTENDED <table> AS JSONto get all the required column info forGetColumnsExtendedAsyncthen combine and join these info into the result. As this SQLDESC TABLE EXTENDED <table> AS JSONis only available in Databricks Runtime 16.2 or above, it will check theServerProtocolVersion. if it does not meet the requirement, it will fallback the implementation of base class.Change
DescTableExtendedResultthat represents the result ofDESC TABLE EXTENDED <table> AS JSON(see format here). It alsotable_constraintsto the structured primary key and foreign key constraintsDataType,ColumnSize,FullTypeNamewhich are calculated from the column type and type specific propertiesHiveServer2Statementto protected so that they can be used/overridden in subclassDatabricksStatementPrimaryKeyFieldsForeignKeyFieldsPrimaryKeyPrefixForeignKeyPrefixGetColumnsExtendedAsyncCreateEmptyExtendedColumnsResultDatabricksStatementwith the changes belowGetColumnsExtendedAsyncinDatabricksStatement, it executes queryDESC TABLE EXTENDED <table> AS JSONto get all the required info and then json them into the QueryResultGetColumnsAsyncto a reusable methodCreateColumnMetadataSchemaGetColumnsAsyncto a reusable methodCreateColumnMetadataEmptyArrayadbc.databricks.use_desc_table_extendedCanUseDescTableExtendedinDatabricksConnection,DatabricksStatementwill call it to decide if it will overrideGetColumnsExtendedAsyncStatementTest:CanGetColumnsExtendedTesting
DescTableExtendedResultTestto cover all the deserialization and parsing cases from raw result ofDESC TABLE EXTENDED <table> AS JSONColumnsExtendedrelevant test cases inDatabricks/StatementTest