This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 6bf4d17923 fix(go/driver/flightsql): send the transaction id on bulk
ingest (#5028)
6bf4d17923 is described below
commit 6bf4d179230b34fd4b959a6f759d58475b0b0619
Author: Jacob <[email protected]>
AuthorDate: Fri Nov 13 02:59:27 2026 +0100
fix(go/driver/flightsql): send the transaction id on bulk ingest (#5028)
With autocommit off, the Flight SQL driver opened a transaction but sent
bulk ingest without its `transaction_id`. The driver now sets
`TransactionId` on `CommandStatementIngest` from the open transaction.
Closes #5027.
Assisted-by: Claude Opus 5.5
---
go/driver/flightsql/flightsql_adbc_server_test.go | 39 +++++++++++++++++++++++
go/driver/flightsql/flightsql_bulk_ingest.go | 3 ++
2 files changed, 42 insertions(+)
diff --git a/go/driver/flightsql/flightsql_adbc_server_test.go
b/go/driver/flightsql/flightsql_adbc_server_test.go
index 3ece32edc5..19d2b9f569 100644
--- a/go/driver/flightsql/flightsql_adbc_server_test.go
+++ b/go/driver/flightsql/flightsql_adbc_server_test.go
@@ -2747,6 +2747,14 @@ func (srv *BulkIngestTestServer)
DoPutCommandStatementIngest(ctx context.Context
return totalRows, nil
}
+func (srv *BulkIngestTestServer) BeginTransaction(context.Context,
flightsql.ActionBeginTransactionRequest) ([]byte, error) {
+ return []byte("ingest-txn"), nil
+}
+
+func (srv *BulkIngestTestServer) EndTransaction(context.Context,
flightsql.ActionEndTransactionRequest) error {
+ return nil
+}
+
func (srv *BulkIngestTestServer) GetIngestedData() []arrow.RecordBatch {
srv.mu.Lock()
defer srv.mu.Unlock()
@@ -2776,6 +2784,7 @@ type BulkIngestTests struct {
func (suite *BulkIngestTests) SetupSuite() {
suite.server = &BulkIngestTestServer{}
+
suite.Require().NoError(suite.server.RegisterSqlInfo(flightsql.SqlInfoFlightSqlServerTransaction,
int32(flightsql.SqlTransactionTransaction)))
suite.DoSetupSuite(suite.server, nil, nil)
}
@@ -2825,6 +2834,36 @@ func (suite *BulkIngestTests) TestBulkIngestCreate() {
requests := suite.server.GetIngestRequests()
suite.Require().Len(requests, 1)
suite.Equal("test_table", requests[0].GetTable())
+ suite.Empty(requests[0].GetTransactionId())
+}
+
+func (suite *BulkIngestTests) TestBulkIngestInTransaction() {
+
suite.Require().NoError(suite.cnxn.(adbc.PostInitOptions).SetOption(adbc.OptionKeyAutoCommit,
adbc.OptionValueDisabled))
+
+ stmt, err := suite.cnxn.NewStatement()
+ suite.Require().NoError(err)
+ defer validation.CheckedClose(suite.T(), stmt)
+
+ suite.Require().NoError(stmt.SetOption(adbc.OptionKeyIngestTargetTable,
"test_table"))
+ suite.Require().NoError(stmt.SetOption(adbc.OptionKeyIngestMode,
adbc.OptionValueIngestModeAppend))
+
+ schema := arrow.NewSchema([]arrow.Field{
+ {Name: "id", Type: arrow.PrimitiveTypes.Int64, Nullable: false},
+ }, nil)
+ bldr := array.NewRecordBuilder(memory.DefaultAllocator, schema)
+ defer bldr.Release()
+ bldr.Field(0).(*array.Int64Builder).AppendValues([]int64{1, 2}, nil)
+ rec := bldr.NewRecordBatch()
+ defer rec.Release()
+
+ suite.Require().NoError(stmt.Bind(context.Background(), rec))
+ nRows, err := stmt.ExecuteUpdate(context.Background())
+ suite.Require().NoError(err)
+ suite.Equal(int64(2), nRows)
+
+ requests := suite.server.GetIngestRequests()
+ suite.Require().Len(requests, 1)
+ suite.Equal([]byte("ingest-txn"), requests[0].GetTransactionId())
}
func (suite *BulkIngestTests) TestBulkIngestAppend() {
diff --git a/go/driver/flightsql/flightsql_bulk_ingest.go
b/go/driver/flightsql/flightsql_bulk_ingest.go
index 80819a5b0a..f0af64118a 100644
--- a/go/driver/flightsql/flightsql_bulk_ingest.go
+++ b/go/driver/flightsql/flightsql_bulk_ingest.go
@@ -150,6 +150,9 @@ func (s *statement) executeIngest(ctx context.Context)
(nRows int64, err error)
}
ingestOpts := buildExecuteIngestOpts(opts)
+ if s.cnxn.txn != nil {
+ ingestOpts.TransactionId = s.cnxn.txn.ID()
+ }
// Get the record reader to ingest
var rdr array.RecordReader