(ctx context.Context, client *bigquery.Client, table string)
| 62 | } |
| 63 | |
| 64 | func (c *Client) doesTableExist(ctx context.Context, client *bigquery.Client, table string) (bool, error) { |
| 65 | c.logger.Debug().Str("dataset", c.spec.DatasetID).Str("table", table).Msg("Checking existence") |
| 66 | tableRef := client.DatasetInProject(c.spec.ProjectID, c.spec.DatasetID).Table(table) |
| 67 | md, err := tableRef.Metadata(ctx) |
| 68 | if err != nil { |
| 69 | if isAPINotFoundError(err) { |
| 70 | return false, nil |
| 71 | } |
| 72 | c.logger.Error().Str("dataset", c.spec.DatasetID).Str("table", table).Err(err).Msg("Got unexpected error while checking table metadata") |
| 73 | return false, err |
| 74 | } |
| 75 | |
| 76 | c.logger.Debug().Interface("creation_time", md.CreationTime).Msg("Got table metadata") |
| 77 | return true, nil |
| 78 | } |
| 79 | |
| 80 | // wait until we can confirm that table now exists to avoid issues if writes are done |
| 81 | // immediately after the migration |
no test coverage detected