davidhcoe commented on code in PR #697:
URL: https://github.com/apache/arrow-adbc/pull/697#discussion_r1204679363


##########
csharp/src/Apache.Arrow.Adbc.FlightSql/FlightSqlStatement.cs:
##########
@@ -0,0 +1,191 @@
+/*
+ * 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.Threading.Tasks;
+using Apache.Arrow.Adbc.Core;
+using Apache.Arrow.Flight;
+using Grpc.Core;
+
+namespace Apache.Arrow.Adbc.FlightSql
+{
+    /// <summary>
+    /// A Flight SQL implementation of <see cref="AdbcStatement"/>.
+    /// </summary>
+    public class FlightSqlStatement : AdbcStatement
+    {
+        private FlightSqlConnection flightSqlConnection;
+        
+        public FlightSqlStatement(FlightSqlConnection flightSqlConnection)
+        {
+            this.flightSqlConnection = flightSqlConnection;
+        }
+
+        public override async ValueTask<QueryResult> ExecuteQueryAsync()
+        {
+            FlightInfo info = await GetInfo(this.SqlQuery, 
this.flightSqlConnection.Metadata);
+
+            return new QueryResult(info.TotalRecords, new 
FlightSqlResult(this.flightSqlConnection, info));
+        }
+
+        public override QueryResult ExecuteQuery()
+        {
+            return ExecuteQueryAsync().Result;
+        }
+
+        public override UpdateResult ExecuteUpdate()
+        {
+            throw new NotImplementedException();
+        }
+
+        public async ValueTask<FlightInfo> GetInfo(string query, Metadata 
headers)
+        {
+            FlightDescriptor commandDescripter = 
FlightDescriptor.CreateCommandDescriptor(query);
+
+            return await 
this.flightSqlConnection.FlightClient.GetInfo(commandDescripter, 
headers).ResponseAsync;
+        }
+
+        /// <summary>
+        /// Gets a value from the Arrow array at the specified index using the 
Arrow field for metadata.
+        /// </summary>
+        /// <param name="arrowArray"></param>
+        /// <param name="field"></param>
+        /// <param name="index"></param>
+        /// <returns></returns>
+        public override object GetValue(IArrowArray arrowArray, Field field, 
int index)

Review Comment:
   Similar to the explanation for ConvertArrowType, it's here for each driver 
to interpret the value. Again, in Snowflake, if the type is an Int64Array, but 
the logical type is _TIME_, then some special calculations need to be performed 
to convert that long value to a DateTime value in C#. There are several others, 
but these types of nuances are why I left it up to the drivers to implement.



-- 
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

Reply via email to