Skip to content

Commit 573a326

Browse files
authored
fix(csharp/src/Drivers/Databricks): Change fallback check of Databricks.GetColumnsExtendedAsync (apache#3121)
# PR Description ### Motivation When `DESC TABLE EXTENDED {fullTableName} AS JSON` fails to run, we will fallback base class `GetColumnsExtendedAsync` which calls 3 metadata query to get the info, but the current check is based on the error message, which is not accurate, instead, we can check the `SqlState` = `42601` which is the error of SQL syntax error, it means the command is not supported by the runtime, then we can fallback to the base class ### Changes - Update the fallback condition check in `Databricks` `GetColumnsExtendedAsync` ### Testing - End-to-end test with the runtime does not support the command
1 parent bc48e18 commit 573a326

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

csharp/src/Drivers/Databricks/DatabricksStatement.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,11 @@ protected override async Task<QueryResult> GetColumnsExtendedAsync(CancellationT
530530
{
531531
descResult = await descStmt.ExecuteQueryAsync();
532532
}
533-
catch (HiveServer2Exception ex) when (ex.Message.Contains("Error running query"))
533+
catch (HiveServer2Exception ex) when (ex.SqlState == "42601")
534534
{
535-
// Fallback to base implementation
536-
Debug.WriteLine($"[ERROR] Failed to run {query}. Fallback to base::GetColumnsExtendedAsync.Error message:{ex.Message}");
535+
// 42601 is error code of syntax error, which this command (DESC TABLE EXTENDED ... AS JSON) is not supported by current DBR
536+
// So we should fallback to base implementation
537+
Debug.WriteLine($"[WARN] Failed to run {query} (reason={ex.Message}). Fallback to base::GetColumnsExtendedAsync.");
537538
return await base.GetColumnsExtendedAsync(cancellationToken);
538539
}
539540

0 commit comments

Comments
 (0)