CurtHagenlocher commented on code in PR #44783: URL: https://github.com/apache/arrow/pull/44783#discussion_r2021649610
########## csharp/src/Apache.Arrow.Flight.Sql/Transaction.cs: ########## @@ -0,0 +1,48 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Apache.Arrow.Flight.Sql; + +using Google.Protobuf; // Ensure you have the Protobuf dependency + +public readonly struct Transaction +{ + private static readonly ByteString TransactionIdDefaultValue = ByteString.Empty; + + private readonly ByteString _transactionId; + + public ByteString TransactionId => _transactionId ?? TransactionIdDefaultValue; + + public static readonly Transaction NoTransaction = new(TransactionIdDefaultValue); + + public Transaction(ByteString transactionId) + { + _transactionId = ProtoPreconditions.CheckNotNull(transactionId, nameof(transactionId)); + } + + public Transaction(string transactionId) + { + _transactionId = ByteString.CopyFromUtf8(transactionId); + } + + public bool IsValid() => _transactionId.Length > 0; Review Comment: ```suggestion public bool IsValid => _transactionId.Length > 0; ``` ########## csharp/src/Apache.Arrow.Flight.Sql/PreparedStatement.cs: ########## @@ -0,0 +1,383 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Apache.Arrow.Flight.Sql.Client; +using Arrow.Flight.Protocol.Sql; +using Google.Protobuf; +using Grpc.Core; + +namespace Apache.Arrow.Flight.Sql; + +public class PreparedStatement : IDisposable +{ + private readonly FlightSqlClient _client; + private readonly string _handle; + private Schema _datasetSchema; + private Schema _parameterSchema; Review Comment: These are still unused as of the latest iteration. They're set by the constructor and never referenced again. ########## csharp/src/Apache.Arrow.Flight.Sql/FlightExtensions.cs: ########## @@ -0,0 +1,41 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using Google.Protobuf; +using Google.Protobuf.WellKnownTypes; + +namespace Apache.Arrow.Flight.Sql; + +internal static class FlightExtensions +{ + public static byte[] PackAndSerialize(this IMessage command) => Any.Pack(command).ToByteArray(); + + public static T ParseAndUnpack<T>(this ByteString source) where T : IMessage<T>, new() => + Any.Parser.ParseFrom(source).Unpack<T>(); + + public static int ExtractRowCount(this RecordBatch batch) Review Comment: Why isn't this just `RecordBatch.Length`? ########## csharp/src/Apache.Arrow.Flight.Sql/DoPutResult.cs: ########## @@ -0,0 +1,54 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Threading.Tasks; +using Apache.Arrow.Flight.Client; +using Grpc.Core; + +namespace Apache.Arrow.Flight.Sql; + +public class DoPutResult +{ + public FlightClientRecordBatchStreamWriter Writer { get; } + public IAsyncStreamReader<FlightPutResult> Reader { get; } + + public DoPutResult(FlightClientRecordBatchStreamWriter writer, IAsyncStreamReader<FlightPutResult> reader) + { + Writer = writer; + Reader = reader; + } + + /// <summary> + /// Reads the metadata asynchronously from the reader. + /// </summary> + /// <returns>A ByteString containing the metadata read from the reader.</returns> + public async Task<Google.Protobuf.ByteString> ReadMetadataAsync() Review Comment: So at least for this method, we expect that `Reader.MoveNext()` will be working on data already in memory vs coming in over the network? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org