Skip to content

Commit a1d706e

Browse files
authored
fix(bigquery-spec)!: Move batch_size from the plugin spec to the top level spec (#6092)
<!-- 🎉 Thank you for making CloudQuery awesome by submitting a PR 🎉 --> #### Summary Same as #6090 not from a fork so tests can pass. Fixes #6070 With the SDK level batching the configuration that "takes" is now at the top spec level. Setting `batch_size` at the plugin level has no impact <!-- Use the following steps to ensure your PR is ready to be reviewed - [ ] Read the [contribution guidelines](../blob/main/CONTRIBUTING.md) 🧑‍🎓 - [ ] Test locally on your own infrastructure - [ ] Run `go fmt` to format your code 🖊 - [ ] Lint your changes via `golangci-lint run` 🚨 (install golangci-lint [here](https://golangci-lint.run/usage/install/#local-installation)) - [ ] Update or add tests 🧪 - [ ] Ensure the status checks below are successful ✅ --->
1 parent 1906d28 commit a1d706e

6 files changed

Lines changed: 9 additions & 14 deletions

File tree

plugins/destination/bigquery/client/client.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type Client struct {
1717
logger zerolog.Logger
1818
spec specs.Destination
1919
metrics destination.Metrics
20-
batchSize int
2120
pluginSpec Spec
2221
client *bigquery.Client
2322
}
@@ -41,7 +40,6 @@ func New(ctx context.Context, logger zerolog.Logger, destSpec specs.Destination)
4140
}
4241

4342
c.pluginSpec = spec
44-
c.batchSize = spec.BatchSize
4543

4644
// the context here is used for token refresh so this is workaround as suggested
4745
// https://github.com/googleapis/google-cloud-go/issues/946

plugins/destination/bigquery/client/spec.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,12 @@ type Spec struct {
3434
DatasetLocation string `json:"dataset_location"`
3535
TimePartitioning TimePartitioningOption `json:"time_partitioning"`
3636
ServiceAccountKeyJSON string `json:"service_account_key_json"`
37-
BatchSize int `json:"batch_size,omitempty"`
3837
}
3938

40-
const defaultBatchSize = 1000
41-
4239
func (s *Spec) SetDefaults() {
4340
if s.TimePartitioning == "" {
4441
s.TimePartitioning = TimePartitioningOptionNone
4542
}
46-
if s.BatchSize <= 0 {
47-
s.BatchSize = defaultBatchSize
48-
}
4943
}
5044

5145
func (s *Spec) Validate() error {

plugins/destination/bigquery/client/write.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
)
1111

1212
const (
13-
batchSize = 1000
1413
writeTimeout = 5 * time.Minute
1514
)
1615

plugins/destination/bigquery/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ const (
1212
)
1313

1414
func main() {
15-
p := destination.NewPlugin("bigquery", plugin.Version, client.New, destination.WithManagedWriter())
15+
p := destination.NewPlugin("bigquery", plugin.Version, client.New, destination.WithManagedWriter(), destination.WithDefaultBatchSize(1000))
1616
serve.Destination(p, serve.WithDestinationSentryDSN(sentryDSN))
1717
}

website/pages/docs/plugins/destinations/bigquery/overview.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ This is the top-level spec used by the BigQuery destination plugin.
9090

9191
GCP service account key content. This allows for using different service accounts for the GCP source and BigQuery destination. If using service account keys, it is best to use [environment or file variable substitution](/docs/advanced-topics/environment-variable-substitution).
9292

93-
- `batch_size` (int, optional. Default: 1000)
94-
95-
Number of rows to insert in a single batch.
96-
9793
## Underlying library
9894

9995
We use the official [cloud.google.com/go/bigquery](https://pkg.go.dev/cloud.google.com/go/bigquery) package for database connection.

website/pages/docs/reference/destination-spec.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ Specifies the update method to use when inserting rows. The exact semantics depe
6161
- `overwrite`: Same as `overwrite-delete-stale`, but doesn't delete stale rows from previous `sync`s.
6262
- `append`: Rows are never overwritten or deleted, only appended.
6363

64+
{/*<!-- vale off -->*/}
65+
### batch_size
66+
{/*<!-- vale on -->*/}
67+
68+
(`int`, optional)
69+
70+
The number of resources to insert in a single batch. Only relevant for plugins that utilize batching. Each plugin has its own default value.
71+
6472
### spec
6573

6674
(`object`, optional)

0 commit comments

Comments
 (0)