Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions csharp/src/Client/AdbcCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,12 @@ public override CommandType CommandType

/// <summary>
/// Gets or sets the name of the command timeout property for the underlying ADBC driver.
/// When set, <see cref="CommandTimeout"/> will propagate the value to the driver via this property.
/// When not set, <see cref="CommandTimeout"/> only stores the value locally.
/// </summary>
public string AdbcCommandTimeoutProperty
public string? AdbcCommandTimeoutProperty
{
get
{
if (string.IsNullOrEmpty(_commandTimeoutProperty))
throw new InvalidOperationException("CommandTimeoutProperty is not set.");

return _commandTimeoutProperty!;
}
get => _commandTimeoutProperty;
set => _commandTimeoutProperty = value;
}

Expand All @@ -147,9 +143,11 @@ public override int CommandTimeout
get => _timeout;
set
{
// ensures the property exists before setting the CommandTimeout value
string property = AdbcCommandTimeoutProperty;
_adbcStatement.SetOption(property, value.ToString(CultureInfo.InvariantCulture));
// if the driver property is set, propagate the timeout value to the driver
if (!string.IsNullOrEmpty(_commandTimeoutProperty))
{
_adbcStatement.SetOption(_commandTimeoutProperty!, value.ToString(CultureInfo.InvariantCulture));
}
_timeout = value;
}
}
Expand Down
6 changes: 3 additions & 3 deletions csharp/test/Apache.Arrow.Adbc.Tests/Client/ClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ internal void TestConnectionStringParsing(ConnectionStringExample connectionStri

if (!string.IsNullOrEmpty(connectionStringExample.CommandTimeoutProperty))
{
Assert.True(cmd.AdbcCommandTimeoutProperty == connectionStringExample.CommandTimeoutProperty);
Assert.True(cmd.CommandTimeout == connectionStringExample.CommandTimeout);
Assert.Equal(connectionStringExample.CommandTimeoutProperty, cmd.AdbcCommandTimeoutProperty);
Assert.Equal(connectionStringExample.CommandTimeout, cmd.CommandTimeout);
}
else
{
Assert.Throws<InvalidOperationException>(() => cmd.AdbcCommandTimeoutProperty);
Assert.Null(cmd.AdbcCommandTimeoutProperty);
}
}
}
Expand Down
Loading