Skip to content

Commit

Permalink
Command timeout change in adbc client & improve exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aman252252 committed Nov 26, 2024
1 parent 153c0d8 commit 834221a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion csharp/src/Client/AdbcCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ public override CommandType CommandType
public override int CommandTimeout
{
get => _timeout;
set => _timeout = value;
set
{
_timeout = value;
_adbcStatement.SetOption("adbc.apache.statement.query_timeout_s", value.ToString());
}
}

protected override DbParameterCollection DbParameterCollection
Expand Down
8 changes: 5 additions & 3 deletions csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ internal TCLIService.Client Client

internal async Task OpenAsync()
{
CancellationToken cancellationToken = ApacheUtility.GetCancellationToken(ConnectTimeoutMilliseconds, ApacheUtility.TimeUnit.Milliseconds);
try
{
CancellationToken cancellationToken = ApacheUtility.GetCancellationToken(ConnectTimeoutMilliseconds, ApacheUtility.TimeUnit.Milliseconds);
TTransport transport = await CreateTransportAsync(cancellationToken);
TProtocol protocol = await CreateProtocolAsync(transport, cancellationToken);
_transport = protocol.Transport;
Expand All @@ -95,9 +95,11 @@ internal async Task OpenAsync()

SessionHandle = session.SessionHandle;
}
catch (OperationCanceledException ex)
catch (Exception ex) when (
(ex is TTransportException || ex is OperationCanceledException) &&
cancellationToken.IsCancellationRequested)
{
throw new TimeoutException("The operation timed out while attempting to open a session.", ex);
throw new HiveServer2Exception("The operation timed out while attempting to open a session. Please try increasing connect timeout.");
}
catch (Exception ex)
{
Expand Down
11 changes: 9 additions & 2 deletions csharp/src/Drivers/Apache/Hive2/HiveServer2Statement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Threading.Tasks;
using Apache.Arrow.Ipc;
using Apache.Hive.Service.Rpc.Thrift;
using Thrift.Transport;

namespace Apache.Arrow.Adbc.Drivers.Apache.Hive2
{
Expand Down Expand Up @@ -61,9 +62,15 @@ private async Task<QueryResult> ExecuteQueryAsyncInternal(CancellationToken canc

return new QueryResult(-1, Connection.NewReader(this, schema));
}
catch (OperationCanceledException ex)
catch (Exception ex) when (
(ex is TTransportException || ex is OperationCanceledException) &&
cancellationToken.IsCancellationRequested)
{
throw new TimeoutException("The query execution timed out.", ex);
throw new TimeoutException("The query execution timed out. Consider increasing the query timeout value.");
}
catch (Exception ex)
{
throw new HiveServer2Exception("The query execution timed out.", ex);
}
}

Expand Down

0 comments on commit 834221a

Please sign in to comment.