lidavidm commented on code in PR #3808:
URL: https://github.com/apache/arrow-adbc/pull/3808#discussion_r2659412281
##########
go/adbc/driver/flightsql/flightsql_adbc_server_test.go:
##########
@@ -2692,3 +2696,408 @@ func (suite *GetObjectsTests)
TestMetadataGetObjectsColumnsXdbc() {
})
}
}
+
+// ---- Bulk Ingest Tests --------------------
+
+// BulkIngestTestServer implements a FlightSQL server that supports bulk
ingestion
+type BulkIngestTestServer struct {
+ flightsql.BaseServer
+
+ mu sync.Mutex
+ ingestedData []arrow.RecordBatch
+ ingestRequests []flightsql.StatementIngest
+}
+
+func (srv *BulkIngestTestServer) DoPutCommandStatementIngest(ctx
context.Context, cmd flightsql.StatementIngest, rdr flight.MessageReader)
(int64, error) {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+
+ // Store the ingest request for validation
+ srv.ingestRequests = append(srv.ingestRequests, cmd)
+
+ var totalRows int64
+ for rdr.Next() {
+ rec := rdr.RecordBatch()
+ rec.Retain()
+ srv.ingestedData = append(srv.ingestedData, rec)
+ totalRows += rec.NumRows()
+ }
+
+ if err := rdr.Err(); err != nil {
+ return -1, err
+ }
+
+ return totalRows, nil
+}
+
+func (srv *BulkIngestTestServer) GetIngestedData() []arrow.RecordBatch {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ result := make([]arrow.RecordBatch, len(srv.ingestedData))
+ copy(result, srv.ingestedData)
+ return result
Review Comment:
slices.Clone here too
##########
go/adbc/driver/flightsql/flightsql_adbc_server_test.go:
##########
@@ -2692,3 +2696,408 @@ func (suite *GetObjectsTests)
TestMetadataGetObjectsColumnsXdbc() {
})
}
}
+
+// ---- Bulk Ingest Tests --------------------
+
+// BulkIngestTestServer implements a FlightSQL server that supports bulk
ingestion
+type BulkIngestTestServer struct {
+ flightsql.BaseServer
+
+ mu sync.Mutex
+ ingestedData []arrow.RecordBatch
+ ingestRequests []flightsql.StatementIngest
+}
+
+func (srv *BulkIngestTestServer) DoPutCommandStatementIngest(ctx
context.Context, cmd flightsql.StatementIngest, rdr flight.MessageReader)
(int64, error) {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+
+ // Store the ingest request for validation
+ srv.ingestRequests = append(srv.ingestRequests, cmd)
+
+ var totalRows int64
+ for rdr.Next() {
+ rec := rdr.RecordBatch()
+ rec.Retain()
+ srv.ingestedData = append(srv.ingestedData, rec)
+ totalRows += rec.NumRows()
+ }
+
+ if err := rdr.Err(); err != nil {
+ return -1, err
+ }
+
+ return totalRows, nil
+}
+
+func (srv *BulkIngestTestServer) GetIngestedData() []arrow.RecordBatch {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ result := make([]arrow.RecordBatch, len(srv.ingestedData))
+ copy(result, srv.ingestedData)
+ return result
+}
+
+func (srv *BulkIngestTestServer) GetIngestRequests()
[]flightsql.StatementIngest {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ result := make([]flightsql.StatementIngest, len(srv.ingestRequests))
+ copy(result, srv.ingestRequests)
+ return result
Review Comment:
[`slices.Clone`](https://pkg.go.dev/slices#Clone)?
--
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]