This is an automated email from the ASF dual-hosted git repository.

curth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 7d2b71949 fix(csharp/src/Drivers/Apache): detect sever error when 
polling for response (#2355)
7d2b71949 is described below

commit 7d2b719493ac1e755c01c4a2d2427ac23175a04b
Author: Bruce Irschick <[email protected]>
AuthorDate: Fri Dec 6 17:41:41 2024 -0800

    fix(csharp/src/Drivers/Apache): detect sever error when polling for 
response (#2355)
    
    Checks the return status when polling for response.
    * Must be in the `FINISHED_STATE`. Other states are invalid after
    polling.
    * Difficult to write tests for this without "abusing" the server to
    invoke a server error.
---
 csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs 
b/csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs
index d420edb2b..b603fdcb1 100644
--- a/csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs
+++ b/csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs
@@ -145,6 +145,14 @@ namespace Apache.Arrow.Adbc.Drivers.Apache.Hive2
                 TGetOperationStatusReq request = new(operationHandle);
                 statusResponse = await client.GetOperationStatus(request, 
cancellationToken);
             } while (statusResponse.OperationState == 
TOperationState.PENDING_STATE || statusResponse.OperationState == 
TOperationState.RUNNING_STATE);
+
+            // Must be in the finished state to be valid. If not, typically a 
server error or timeout has occurred.
+            if (statusResponse.OperationState != 
TOperationState.FINISHED_STATE)
+            {
+                throw new HiveServer2Exception(statusResponse.ErrorMessage, 
AdbcStatusCode.InvalidState)
+                    .SetSqlState(statusResponse.SqlState)
+                    .SetNativeError(statusResponse.ErrorCode);
+            }
         }
 
         private string GetInfoTypeStringValue(TGetInfoType infoType)

Reply via email to