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
42 changes: 42 additions & 0 deletions go/adbc/driver/bigquery/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,45 @@ func TestBuildField(t *testing.T) {
})
}
}

func TestStatementSetGetOptionReservation(t *testing.T) {
cnxn := &connectionImpl{}
st := &statement{cnxn: cnxn}

const reservation = "projects/my-project/locations/US/reservations/my-reservation"

// Initially empty
got, err := st.GetOption(OptionStringQueryReservation)
if err != nil {
t.Fatalf("GetOption returned error: %v", err)
}
if got != "" {
t.Fatalf("expected empty reservation by default, got %q", got)
}

// Set the reservation
if err := st.SetOption(OptionStringQueryReservation, reservation); err != nil {
t.Fatalf("SetOption returned error: %v", err)
}

// Round-trip via GetOption
got, err = st.GetOption(OptionStringQueryReservation)
if err != nil {
t.Fatalf("GetOption returned error: %v", err)
}
if got != reservation {
t.Fatalf("expected %q, got %q", reservation, got)
}

// Clear the reservation
if err := st.SetOption(OptionStringQueryReservation, ""); err != nil {
t.Fatalf("SetOption(empty) returned error: %v", err)
}
got, err = st.GetOption(OptionStringQueryReservation)
if err != nil {
t.Fatalf("GetOption returned error: %v", err)
}
if got != "" {
t.Fatalf("expected empty after clear, got %q", got)
}
}
15 changes: 10 additions & 5 deletions go/adbc/driver/bigquery/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import (
)

const (
OptionStringAuthType = "adbc.bigquery.sql.auth_type"
OptionStringAuthType = "adbc.bigquery.sql.auth_type"
OptionStringAPIEndpoint = "adbc.bigquery.sql.api_endpoint"
OptionStringLocation = "adbc.bigquery.sql.location"
OptionStringProjectID = "adbc.bigquery.sql.project_id"
OptionStringDatasetID = "adbc.bigquery.sql.dataset_id"
OptionStringTableID = "adbc.bigquery.sql.table_id"
OptionStringLocation = "adbc.bigquery.sql.location"
OptionStringProjectID = "adbc.bigquery.sql.project_id"
OptionStringDatasetID = "adbc.bigquery.sql.dataset_id"
OptionStringTableID = "adbc.bigquery.sql.table_id"

OptionValueAuthTypeDefault = "adbc.bigquery.sql.auth_type.auth_bigquery"

Expand Down Expand Up @@ -77,6 +77,11 @@ const (
OptionBoolQueryDryRun = "adbc.bigquery.sql.query.dry_run"
OptionBoolQueryCreateSession = "adbc.bigquery.sql.query.create_session"
OptionIntQueryJobTimeout = "adbc.bigquery.sql.query.job_timeout"
// OptionStringQueryReservation specifies the BigQuery reservation to use for query
// execution. The value must be a full reservation resource path of the form
// "projects/<project>/locations/<location>/reservations/<reservation>".
// When set, the query job is submitted under the specified reservation.
OptionStringQueryReservation = "adbc.bigquery.sql.query.reservation"

OptionIntQueryResultBufferSize = "adbc.bigquery.sql.query.result_buffer_size"
OptionIntQueryPrefetchConcurrency = "adbc.bigquery.sql.query.prefetch_concurrency"
Expand Down
4 changes: 4 additions & 0 deletions go/adbc/driver/bigquery/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ func (st *statement) GetOption(key string) (string, error) {
return strconv.FormatBool(st.queryConfig.DryRun), nil
case OptionBoolQueryCreateSession:
return strconv.FormatBool(st.queryConfig.CreateSession), nil
case OptionStringQueryReservation:
return st.queryConfig.Reservation, nil
case OptionBoolQueryLinkFailedJob:
return strconv.FormatBool(st.linkFailedJob), nil
case OptionBoolUseStorageApiDisabledClient:
Expand Down Expand Up @@ -404,6 +406,8 @@ func (st *statement) SetOption(key string, v string) error {
} else {
return err
}
case OptionStringQueryReservation:
st.queryConfig.Reservation = v
case OptionStringIngestPath:
st.ingestPath = v
case OptionStringIngestFileDelimiter:
Expand Down
Loading