zeroshade commented on code in PR #1457:
URL: https://github.com/apache/arrow-adbc/pull/1457#discussion_r1459698721


##########
go/adbc/driver/flightsql/flightsql_statement.go:
##########
@@ -485,13 +530,91 @@ func (s *statement) ExecutePartitions(ctx 
context.Context) (*arrow.Schema, adbc.
 
        var (
                info *flight.FlightInfo
+               poll *flight.PollInfo
                out  adbc.Partitions
                sc   *arrow.Schema
                err  error
        )
 
        var header, trailer metadata.MD
-       if s.prepared != nil {
+       if s.incrementalState != nil {
+               if s.incrementalState.complete {
+                       schema := s.incrementalState.schema
+                       totalRecords := 
s.incrementalState.previousInfo.TotalRecords
+                       // Reset the statement for reuse
+                       s.incrementalState = &incrementalState{}
+                       s.progress = 0.0
+                       return schema, adbc.Partitions{}, totalRecords, nil
+               }
+
+               backoff := 100 * time.Millisecond
+               for {
+                       // Keep polling until the query completes or we get new 
partitions
+                       if s.prepared != nil {
+                               poll, err = s.prepared.ExecutePoll(ctx, 
s.incrementalState.retryDescriptor, grpc.Header(&header), 
grpc.Trailer(&trailer), s.timeouts)
+                       } else {
+                               poll, err = s.query.poll(ctx, s.cnxn, 
s.incrementalState.retryDescriptor, grpc.Header(&header), 
grpc.Trailer(&trailer), s.timeouts)
+                       }
+                       if err != nil {
+                               break
+                       }
+                       info = poll.GetInfo()
+                       if info == nil {
+                               // The server is misbehaving
+                               // XXX: should we also issue a query 
cancellation?
+                               s.incrementalState = &incrementalState{}
+                               s.progress = 0.0
+                               return nil, adbc.Partitions{}, -1, adbc.Error{
+                                       Msg:  "[Flight SQL] Server returned a 
PollInfo with no FlightInfo",
+                                       Code: adbc.StatusInternal,
+                               }
+                       }
+                       info = &flight.FlightInfo{

Review Comment:
   Could we just use 
https://pkg.go.dev/google.golang.org/[email protected]/proto#Clone instead?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to