InitBigQuery initializes a BigQuery dataset/table in the project. If the dataset/table already exists, it is not duplicated.
(ctx context.Context, projectID, datasetID, tableID string, opts []option.ClientOption)
| 285 | |
| 286 | // InitBigQuery initializes a BigQuery dataset/table in the project. If the dataset/table already exists, it is not duplicated. |
| 287 | func InitBigQuery(ctx context.Context, projectID, datasetID, tableID string, opts []option.ClientOption) error { |
| 288 | client, err := bq.NewClient(ctx, projectID, opts...) |
| 289 | if err != nil { |
| 290 | return fmt.Errorf("failed to initialize client on project %s: %v", projectID, err) |
| 291 | } |
| 292 | defer client.Close() |
| 293 | |
| 294 | dataset := client.Dataset(datasetID) |
| 295 | if err := dataset.Create(ctx, nil); err != nil && !checkDuplicateError(err) { |
| 296 | return fmt.Errorf("failed to create dataset: %s: %v", datasetID, err) |
| 297 | } |
| 298 | |
| 299 | table := dataset.Table(tableID) |
| 300 | schema, err := bq.InferSchema(Suite{}) |
| 301 | if err != nil { |
| 302 | return fmt.Errorf("failed to infer schema: %v", err) |
| 303 | } |
| 304 | |
| 305 | if err := table.Create(ctx, &bq.TableMetadata{Schema: schema}); err != nil && !checkDuplicateError(err) { |
| 306 | return fmt.Errorf("failed to create table: %s: %v", tableID, err) |
| 307 | } |
| 308 | return nil |
| 309 | } |
| 310 | |
| 311 | // NewBenchmarkWithMetric creates a new sending to BigQuery, initialized with a |
| 312 | // single iteration and single metric. |
nothing calls this directly
no test coverage detected
searching dependent graphs…