Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 16 additions & 0 deletions PORT_REVIEW.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<!--
Copyright (c) 2026 ADBC Drivers Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Port review: `dbt-labs/arrow-adbc` → `bigquery-adbc`

Every commit in `dbt-labs/arrow-adbc` (fork) that isn't in
Expand Down
2 changes: 1 addition & 1 deletion go/csv_ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (st *statement) executeCSVIngest(ctx context.Context) (array.RecordReader,
if err != nil {
return nil, -1, fmt.Errorf("[bq] open %q: %w", st.ingestPath, err)
}
defer file.Close()
defer func() { _ = file.Close() }()

if st.queryConfig.Dst == nil {
return nil, -1, adbc.Error{
Expand Down
17 changes: 10 additions & 7 deletions go/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,6 @@ const (
// return null over the Storage Read API.
OptionBoolUseStorageApiDisabledClient = "adbc.bigquery.sql.query.use_storage_api_disabled_client"

// ContextKeyUseStorageApiDisabledClient signals to runQuery via
// context that it should fall back to the row-based iterator
// (bigquery.RowIterator + rowsToArrowRecordBatch) instead of the
// Storage Read API, so pseudo-columns like _PARTITIONDATE return
// values instead of nulls.
ContextKeyUseStorageApiDisabledClient = "USE_STORAGE_API_DISABLED_CLIENT"

// TODO (harry): migrate the options with prefix "adbc.bigquery.sql" to use the newer format
// TODO (harry): add the old option values to optionRemapping map for backward-compatibility
// Copy table options — copy_table.source and copy_table.destination each accept
Expand Down Expand Up @@ -258,6 +251,16 @@ const (
OptionValueCompressionZSTD = "zstd"
)

// contextKey namespaces context values set by this driver, so they can't
// collide with keys from other packages sharing the same context.
type contextKey string

// ContextKeyUseStorageApiDisabledClient signals to runQuery via context that
// it should fall back to the row-based iterator (bigquery.RowIterator +
// rowsToArrowRecordBatch) instead of the Storage Read API, so pseudo-columns
// like _PARTITIONDATE return values instead of nulls.
const ContextKeyUseStorageApiDisabledClient contextKey = "USE_STORAGE_API_DISABLED_CLIENT"

var (
infoVendorVersion string

Expand Down
22 changes: 11 additions & 11 deletions go/python_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (st *statement) executeDataprocCreateBatch(ctx context.Context) (array.Reco
if err != nil {
return nil, -1, fmt.Errorf("[bq] create Dataproc client: %w", err)
}
defer client.Close()
defer func() { _ = client.Close() }()

req := &dataprocpb.CreateBatchRequest{
Parent: st.createBatchReqParent,
Expand All @@ -113,7 +113,7 @@ func (st *statement) executeSubmitJobAsOperation(ctx context.Context) (array.Rec
if err != nil {
return nil, -1, fmt.Errorf("[bq] create Dataproc JobController client: %w", err)
}
defer client.Close()
defer func() { _ = client.Close() }()

req := &dataprocpb.SubmitJobRequest{
ProjectId: st.dataprocProject,
Expand Down Expand Up @@ -194,7 +194,7 @@ func (c *connectionImpl) addExecutionIdentityDetails(ctx context.Context, job *a
if err != nil {
return nil, fmt.Errorf("build http transport: %w", err)
}
var tokenSource oauth2.TokenSource = oauth2.StaticTokenSource(&oauth2.Token{})
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{})
if t, ok := ts.Transport.(*oauth2.Transport); ok {
tokenSource = t.Source
}
Expand All @@ -211,7 +211,7 @@ func (c *connectionImpl) addExecutionIdentityDetails(ctx context.Context, job *a
if err != nil {
return nil, fmt.Errorf("call userinfo: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
Expand Down Expand Up @@ -246,7 +246,7 @@ func (st *statement) getNotebookTemplateName(ctx context.Context) (string, error
if err != nil {
return "", fmt.Errorf("[bq] create notebook client: %w", err)
}
defer client.Close()
defer func() { _ = client.Close() }()

req := &aiplatformpb.ListNotebookRuntimeTemplatesRequest{
Parent: st.createNotebookExecuteJobParent,
Expand Down Expand Up @@ -289,7 +289,7 @@ func (st *statement) executeCreateNotebookExecutionJob(ctx context.Context) (arr
if err != nil {
return nil, -1, fmt.Errorf("[bq] create notebook client: %w", err)
}
defer client.Close()
defer func() { _ = client.Close() }()

templateName := ""
if st.createNotebookExecuteJobTemplateId != "" {
Expand Down Expand Up @@ -334,11 +334,11 @@ func (st *statement) executeCreateNotebookExecutionJob(ctx context.Context) (arr

waitCtx, cancel := context.WithTimeout(ctx, time.Duration(st.dataprocPoolingTimeout)*time.Second)
defer cancel()
retrievedJob, err := op.Wait(waitCtx)
if err != nil {
if _, err = op.Wait(waitCtx); err != nil {
return nil, -1, fmt.Errorf("[bq] notebook execution op: %w", err)
}

var retrievedJob *aiplatformpb.NotebookExecutionJob
elapsed := time.Duration(0)
for {
retrievedJob, err = client.GetNotebookExecutionJob(ctx, &aiplatformpb.GetNotebookExecutionJobRequest{Name: jobName})
Expand Down Expand Up @@ -366,7 +366,7 @@ func (st *statement) executeCreateNotebookExecutionJob(ctx context.Context) (arr

gcsClient, err := st.cnxn.newGCSClient(ctx)
if err == nil {
defer gcsClient.Close()
defer func() { _ = gcsClient.Close() }()
if data, err := readJSONFromGCS(ctx, gcsLogURI, gcsClient); err == nil && data != nil {
processGCSNotebookLog(st.cnxn.Logger, data)
}
Expand All @@ -392,7 +392,7 @@ func readJSONFromGCS(ctx context.Context, gcsURI string, storageClient *storage.
if err != nil {
return nil, err
}
defer reader.Close()
defer func() { _ = reader.Close() }()
content, err := io.ReadAll(reader)
if err != nil {
return nil, err
Expand Down Expand Up @@ -443,7 +443,7 @@ func (st *statement) writeToGCS(ctx context.Context) (array.RecordReader, int64,
if err != nil {
return nil, -1, fmt.Errorf("[bq] create GCS client: %w", err)
}
defer client.Close()
defer func() { _ = client.Close() }()

wc := client.Bucket(st.writeGCSBucket).Object(st.writeGCSObjectName).NewWriter(ctx)
if _, err := wc.Write([]byte(st.writeGCSContent)); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go/row_based_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (l *RowBasedArrowIterator) Next() (*bigquery.ArrowRecordBatch, error) {
const batchSize = 1000
rows := make([][]bigquery.Value, 0, batchSize)

for i := 0; i < batchSize; i++ {
for range batchSize {
var row []bigquery.Value
err := l.iter.Next(&row)
if err == iterator.Done {
Expand Down
Loading