Skip to content

[Go] Feat: Add connection option to override Storage Read API endpoint (emulator support) #202

@AlphaJack

Description

@AlphaJack

Problem

connection.go:833 deliberately passes authOptions (no custom endpoint) to EnableStorageReadClient, while the REST client on line 821 receives option.WithEndpoint(c.endpoint):

// Add custom endpoint if specified for BigQuery API client
bigQueryAuthOptions := authOptions
if c.endpoint != "" {
    bigQueryAuthOptions = append(bigQueryAuthOptions, option.WithEndpoint(c.endpoint))
}
client, err := bigquery.NewClient(ctx, c.catalog, bigQueryAuthOptions...)

// Use original authOptions without custom endpoint for Storage Read API
err = client.EnableStorageReadClient(ctx, authOptions...)  // ← no endpoint override

This means the Storage Read API client always connects to bigquerystorage.googleapis.com, with no way to redirect it to a local emulator such as goccy/bigquery-emulator, which correctly implements the BigQuery Storage Read API on a configurable gRPC port.

adbc.bigquery.sql.endpoint redirects the REST Jobs API but has no effect on Storage reads. Binary inspection of libadbc_driver_bigquery.dylib v1.11.2 confirms no storage-related option key exists.

Proposed fix

Add a new connection option (e.g. adbc.bigquery.sql.storage_endpoint) that, when set, appends option.WithEndpoint(storageEndpoint) to the options passed to EnableStorageReadClient:

storageAuthOptions := authOptions
if c.storageEndpoint != "" {
    storageAuthOptions = append(storageAuthOptions, option.WithEndpoint(c.storageEndpoint))
}
err = client.EnableStorageReadClient(ctx, storageAuthOptions...)

This mirrors the existing adbc.bigquery.sql.endpoint pattern exactly.

Impact

Without this, any test suite targeting a local emulator must skip all Arrow type contract verification for the BigQuery adapter. The driver fails at read time with:

Unauthorized: [bq] Arrow reader requires roles/bigquery.readSessionUser

even when the emulator accepts the connection and executes the query correctly via the Jobs API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions