Mandukhai-Alimaa commented on code in PR #3150:
URL: https://github.com/apache/arrow-adbc/pull/3150#discussion_r2214576983


##########
go/adbc/ext.go:
##########
@@ -78,3 +81,81 @@ type OTelTracing interface {
        // Gets the initial span attributes for any newly started span.
        GetInitialSpanAttributes() []attribute.KeyValue
 }
+
+// IngestStreamOption bundles the IngestStream options.
+// Driver specific options can go into Extra.
+type IngestStreamOption struct {
+       // Optional catalog/catalogue name
+       Catalog string
+
+       // Optional database schema (namespace)
+       DBSchema string
+
+       // If true, ingest into a temporary table
+       Temporary bool
+
+       // Driver-specific options
+       Extra map[string]string
+}
+
+// IngestStream is a helper for executing a bulk ingestion. This is a wrapper 
around
+// the five-step boilerplate of NewStatement, SetOption, Bind,
+// Execute, and Close.
+//
+// This is not part of the ADBC API specification.
+func IngestStream(ctx context.Context, cnxn Connection, reader 
array.RecordReader, targetTable, ingestMode string, opt IngestStreamOption) 
(int64, error) {
+       // Create a new statement
+       stmt, err := cnxn.NewStatement()
+       if err != nil {
+               return -1, fmt.Errorf("error during ingestion: NewStatement: 
%w", err)
+       }
+       defer func() {
+               err = errors.Join(err, stmt.Close())
+       }()
+
+       // Bind the record batch stream
+       if err = stmt.BindStream(ctx, reader); err != nil {
+               return -1, fmt.Errorf("error during ingestion: BindStream: %w", 
err)
+       }
+
+       // Set required options
+       if err = stmt.SetOption(OptionKeyIngestTargetTable, targetTable); err 
!= nil {
+               return 0, fmt.Errorf("error during ingestion: 
SetOption(target_table=%s): %w", targetTable, err)

Review Comment:
   Fixed it. I've switched the sentinel back to −1. My pair programmer (AI 
assistant) must have accidentally used 0, and I overlooked it. Thanks for 
catching that!



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