diff --git a/csharp/src/Apache.Arrow.Flight.Sql/Client/FlightSqlClient.cs b/csharp/src/Apache.Arrow.Flight.Sql/Client/FlightSqlClient.cs
index 55c23f66f356b..54feb7ab6c8c2 100644
--- a/csharp/src/Apache.Arrow.Flight.Sql/Client/FlightSqlClient.cs
+++ b/csharp/src/Apache.Arrow.Flight.Sql/Client/FlightSqlClient.cs
@@ -39,10 +39,13 @@ public FlightSqlClient(FlightClient client)
/// A transaction to associate this query with.
/// RPC-layer hints for this call.
/// The FlightInfo describing where to access the dataset.
- public async Task ExecuteAsync(string query, Transaction? transaction = null, FlightCallOptions? options = default)
+ public async Task ExecuteAsync(string query, Transaction transaction = default, FlightCallOptions? options = null)
{
- transaction ??= Transaction.NoTransaction;
-
+ if (transaction == default)
+ {
+ transaction = Transaction.NoTransaction;
+ }
+
if (string.IsNullOrEmpty(query))
{
throw new ArgumentException($"Query cannot be null or empty: {nameof(query)}");
@@ -66,15 +69,18 @@ public async Task ExecuteAsync(string query, Transaction? transactio
}
///
- /// Executes an update query on the server.
+ /// Executes an update SQL command and returns the number of affected rows.
///
/// The UTF8-encoded SQL query to be executed.
/// A transaction to associate this query with. Defaults to no transaction if not provided.
/// RPC-layer hints for this call.
/// The number of rows affected by the operation.
- public async Task ExecuteUpdateAsync(string query, Transaction? transaction = null, FlightCallOptions? options = default)
+ public async Task ExecuteUpdateAsync(string query, Transaction transaction = default, FlightCallOptions? options = null)
{
- transaction ??= Transaction.NoTransaction;
+ if (transaction == default)
+ {
+ transaction = Transaction.NoTransaction;
+ }
if (string.IsNullOrEmpty(query))
{
@@ -104,10 +110,7 @@ public async Task ExecuteUpdateAsync(string query, Transaction? transactio
await foreach (var recordBatch in doGetResult.ConfigureAwait(false))
{
- foreach (var rowCount in recordBatch.ExtractRowCount())
- {
- affectedRows += rowCount;
- }
+ affectedRows += recordBatch.ExtractRowCount();
}
}
@@ -170,9 +173,12 @@ public async IAsyncEnumerable DoActionAsync(FlightAction action, F
/// A transaction to associate this query with
/// Per-RPC options
/// The SchemaResult describing the schema of the result set
- public async Task GetExecuteSchemaAsync(string query, Transaction? transaction = null, FlightCallOptions? options = default)
+ public async Task GetExecuteSchemaAsync(string query, Transaction transaction = default, FlightCallOptions? options = null)
{
- transaction ??= Transaction.NoTransaction;
+ if (transaction == default)
+ {
+ transaction = Transaction.NoTransaction;
+ }
if (string.IsNullOrEmpty(query))
throw new ArgumentException($"Query cannot be null or empty: {nameof(query)}");
@@ -897,12 +903,15 @@ public AsyncServerStreamingCall RollbackAsync(Transaction transact
/// A transaction to associate this query with.
/// RPC-layer hints for this call.
/// The created prepared statement.
- public async Task PrepareAsync(string query, Transaction? transaction = null, FlightCallOptions? options = default)
+ public async Task PrepareAsync(string query, Transaction transaction = default, FlightCallOptions? options = null)
{
if (string.IsNullOrEmpty(query))
throw new ArgumentException("Query cannot be null or empty", nameof(query));
- transaction ??= Transaction.NoTransaction;
+ if (transaction == default)
+ {
+ transaction = Transaction.NoTransaction;
+ }
try
{
diff --git a/csharp/src/Apache.Arrow.Flight.Sql/FlightCallOptions.cs b/csharp/src/Apache.Arrow.Flight.Sql/FlightCallOptions.cs
index d5b275b816a4f..17541b26e7393 100644
--- a/csharp/src/Apache.Arrow.Flight.Sql/FlightCallOptions.cs
+++ b/csharp/src/Apache.Arrow.Flight.Sql/FlightCallOptions.cs
@@ -26,22 +26,13 @@ public FlightCallOptions()
{
Timeout = TimeSpan.FromSeconds(-1);
}
+
// Implement any necessary options for RPC calls
public Metadata Headers { get; set; } = new();
- ///
- /// Gets or sets a token to enable interactive user cancellation of long-running requests.
- ///
- public CancellationToken StopToken { get; set; }
-
///
/// Gets or sets the optional timeout for this call.
/// Negative durations mean an implementation-defined default behavior will be used instead.
///
public TimeSpan Timeout { get; set; }
-
- ///
- /// Gets or sets an optional memory manager to control where to allocate incoming data.
- ///
- public MemoryManager? MemoryManager { get; set; }
}
diff --git a/csharp/src/Apache.Arrow.Flight.Sql/FlightExtensions.cs b/csharp/src/Apache.Arrow.Flight.Sql/FlightExtensions.cs
index 1b9d3e84f25d0..a0936eb7f34e8 100644
--- a/csharp/src/Apache.Arrow.Flight.Sql/FlightExtensions.cs
+++ b/csharp/src/Apache.Arrow.Flight.Sql/FlightExtensions.cs
@@ -14,7 +14,6 @@
// limitations under the License.
using System;
-using System.Collections.Generic;
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
@@ -23,59 +22,20 @@ namespace Apache.Arrow.Flight.Sql;
internal static class FlightExtensions
{
public static byte[] PackAndSerialize(this IMessage command) => Any.Pack(command).ToByteArray();
- public static T ParseAndUnpack(this ByteString source) where T : IMessage, new() => Any.Parser.ParseFrom(source).Unpack();
- public static IEnumerable ExtractRowCount(this RecordBatch batch)
- {
- foreach (var array in batch.Arrays)
- {
- var values = ExtractValues(array);
- foreach (var value in values)
- {
- yield return value switch
- {
- long l => l,
- int i => i != 0 ? i : 0,
- _ => 0L
- };
- }
- }
- }
-
- private static IEnumerable