-
Notifications
You must be signed in to change notification settings - Fork 13
feat(csharp): add enable_fast_metadata_query flag for DESC TABLE EXTENDED #456
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,14 @@ internal class DatabricksStatement : SparkStatement, IHiveServer2Statement | |
| private QueryResult? _lastQueryResult; // Track last query result for telemetry chunk metrics | ||
| internal bool IsInternalCall { get; set; } // Marks if this is a driver-internal operation (e.g., USE SCHEMA) | ||
|
|
||
| /// <summary> | ||
| /// Optional override for the Thrift RunAsync flag on a single statement. When non-null, | ||
| /// takes precedence over the connection-level <see cref="DatabricksConnection.RunAsyncInThrift"/>. | ||
| /// Pairs with the SQL-level STATIC ONLY modifier on DESC TABLE EXTENDED: RunAsync=false | ||
| /// is what tells the warehouse to route the command off the WLM path. | ||
| /// </summary> | ||
| internal bool? RunAsyncOverride { get; set; } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this extra flag? Who is passing this in?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Open to a different shape if you have one in mind — happy to refactor if e.g. you'd prefer a constructor param or a dedicated |
||
|
|
||
| /// <summary> | ||
| /// Telemetry context for the current statement execution, pending emission on Dispose. | ||
| /// Set before calling base.ExecuteQueryAsync()/ExecuteQuery() so that | ||
|
|
@@ -445,7 +453,7 @@ protected override void SetStatementProperties(TExecuteStatementReq statement) | |
| statement.CanDownloadResult = useCloudFetch; | ||
| statement.CanDecompressLZ4Result = canDecompressLz4; | ||
| statement.MaxBytesPerFile = maxBytesPerFile; | ||
| statement.RunAsync = runAsyncInThrift; | ||
| statement.RunAsync = RunAsyncOverride ?? runAsyncInThrift; | ||
|
|
||
| Connection.TrySetGetDirectResults(statement); | ||
|
|
||
|
|
@@ -471,7 +479,11 @@ protected override void SetStatementProperties(TExecuteStatementReq statement) | |
| Activity.Current?.SetTag("statement.cloudfetch.can_decompress_lz4", canDecompressLz4); | ||
| Activity.Current?.SetTag("statement.cloudfetch.max_bytes_per_file", maxBytesPerFile); | ||
| Activity.Current?.SetTag("statement.cloudfetch.max_bytes_per_file_mb", maxBytesPerFile / 1024.0 / 1024.0); | ||
| Activity.Current?.SetTag("statement.property.run_async", runAsyncInThrift); | ||
| Activity.Current?.SetTag("statement.property.run_async", statement.RunAsync); | ||
|
jadewang-db marked this conversation as resolved.
|
||
| if (RunAsyncOverride.HasValue) | ||
| { | ||
| Activity.Current?.SetTag("statement.property.run_async.source", "override"); | ||
| } | ||
|
|
||
| Activity.Current?.AddEvent("statement.set_properties.complete"); | ||
| } | ||
|
|
@@ -972,7 +984,8 @@ protected override async Task<QueryResult> GetColumnsExtendedAsync(CancellationT | |
| { | ||
| activity?.AddEvent("statement.get_columns_extended.start"); | ||
| string? fullTableName = BuildTableName(); | ||
| var canUseDescTableExtended = ((DatabricksConnection)Connection).CanUseDescTableExtended; | ||
| var connection = (DatabricksConnection)Connection; | ||
| var canUseDescTableExtended = connection.CanUseDescTableExtended; | ||
|
|
||
| activity?.SetTag("statement.catalog_name", CatalogName ?? "(none)"); | ||
| activity?.SetTag("statement.schema_name", SchemaName ?? "(none)"); | ||
|
|
@@ -993,13 +1006,24 @@ protected override async Task<QueryResult> GetColumnsExtendedAsync(CancellationT | |
| return baseResult; | ||
| } | ||
|
|
||
| string query = $"DESC TABLE EXTENDED {fullTableName} AS JSON"; | ||
| // Fast metadata: STATIC ONLY (runtime PR #198486) bypasses the server's WLM | ||
| // path. Both the SQL keyword and RunAsync=false are required to take effect. | ||
| bool useFastMetadataQuery = connection.UseFastMetadataQuery; | ||
| string query = useFastMetadataQuery | ||
| ? $"DESC TABLE EXTENDED {fullTableName} AS JSON STATIC ONLY" | ||
| : $"DESC TABLE EXTENDED {fullTableName} AS JSON"; | ||
| activity?.AddEvent("statement.desc_table_extended.executing_query", [ | ||
| new("query_summary", query.Length > 100 ? query.Substring(0, 100) + "..." : query) | ||
| new("query_summary", query.Length > 100 ? query.Substring(0, 100) + "..." : query), | ||
| new("fast_metadata_query", useFastMetadataQuery) | ||
| ]); | ||
|
|
||
| using var descStmt = Connection.CreateStatement(); | ||
| using var descStmt = (DatabricksStatement)connection.CreateStatement(); | ||
| descStmt.SqlQuery = query; | ||
|
|
||
| if (useFastMetadataQuery) | ||
| { | ||
| descStmt.RunAsyncOverride = false; | ||
| } | ||
| QueryResult descResult; | ||
|
|
||
| try | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.