Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions go/adbc/ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ func IngestStream(ctx context.Context, cnxn Connection, reader array.RecordReade
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
// Set required options before binding
if err = stmt.SetOption(OptionKeyIngestTargetTable, targetTable); err != nil {
return -1, fmt.Errorf("error during ingestion: SetOption(target_table=%s): %w", targetTable, err)
}
if err = stmt.SetOption(OptionKeyIngestMode, ingestMode); err != nil {
return -1, fmt.Errorf("error during ingestion: SetOption(mode=%s): %w", ingestMode, err)
}

// Bind the record batch stream
if err = stmt.BindStream(ctx, reader); err != nil {
return -1, fmt.Errorf("error during ingestion: BindStream: %w", err)
}

// Set other options if provided
if opt.Catalog != "" {
if err = stmt.SetOption(OptionValueIngestTargetCatalog, opt.Catalog); err != nil {
Expand Down Expand Up @@ -167,19 +167,19 @@ func IngestStreamContext(ctx context.Context, cnxn ConnectionWithContext, reader
err = errors.Join(err, stmt.Close(ctx))
}()

// 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
// Set required options before binding (some drivers require target first)
if err = stmt.SetOption(ctx, OptionKeyIngestTargetTable, targetTable); err != nil {
return -1, fmt.Errorf("error during ingestion: SetOption(target_table=%s): %w", targetTable, err)
}
if err = stmt.SetOption(ctx, OptionKeyIngestMode, ingestMode); err != nil {
return -1, fmt.Errorf("error during ingestion: SetOption(mode=%s): %w", ingestMode, err)
}

// Bind the record batch stream
if err = stmt.BindStream(ctx, reader); err != nil {
return -1, fmt.Errorf("error during ingestion: BindStream: %w", err)
}

// Set other options if provided
if opt.Catalog != "" {
if err = stmt.SetOption(ctx, OptionValueIngestTargetCatalog, opt.Catalog); err != nil {
Expand Down
Loading