Skip to content

fix(go/adbc/drivermgr): adjust ingest helper to set target before BindStream#4308

Open
arnoldwakim wants to merge 1 commit into
apache:mainfrom
arnoldwakim:fix/go-adbc-ingest-helper
Open

fix(go/adbc/drivermgr): adjust ingest helper to set target before BindStream#4308
arnoldwakim wants to merge 1 commit into
apache:mainfrom
arnoldwakim:fix/go-adbc-ingest-helper

Conversation

@arnoldwakim
Copy link
Copy Markdown

Summary

Reorder IngestStream and IngestStreamContext to set OptionKeyIngestTargetTable and OptionKeyIngestMode before calling BindStream, matching drivers that require ingest targets up front (e.g., FlightSQL).

Keep all other ingest option handling and execution flow unchanged.

Evidence (FlightSQL requirement):

go/adbc/driver/flightsql/flightsql_statement.go:630-656:

func (s *statement) BindStream(_ context.Context, stream array.RecordReader) error {
	// For bulk ingest, bind to the statement
	if s.targetTable != "" {
		if s.bound != nil {
			s.bound.Release()
			s.bound = nil
		}
		if s.streamBind != nil {
			s.streamBind.Release()
		}
		s.streamBind = stream
		if s.streamBind != nil {
			s.streamBind.Retain()
		}
		return nil
	}

	if s.prepared == nil {
		return adbc.Error{
			Msg:  "[Flight SQL Statement] must call Prepare or set IngestTargetTable before calling Bind",
			Code: adbc.StatusInvalidState}
	}

	// calls retain
	s.prepared.SetRecordReader(stream)
	return nil
}

The current non-patched code, raises the error:

[Flight SQL Statement] must call Prepare or set IngestTargetTable before calling Bind

@arnoldwakim arnoldwakim requested a review from zeroshade as a code owner May 10, 2026 10:31
Copy link
Copy Markdown
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is reasonable but I feel like we should fix the FlightSQL driver as well, @zeroshade

Copy link
Copy Markdown
Member

@zeroshade zeroshade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, we should fix the FlightSQL driver. But more importantly, can you add a test here?

@arnoldwakim
Copy link
Copy Markdown
Author

I will, add a test, did you have something particular in mind or just asserting that the stream was bound?

Also, are you expecting me to fix the FlightSQL driver or is it something one of you wants to tackle?

Thanks for the swift review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants