MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / doesTableExist

Method doesTableExist

plugins/destination/bigquery/client/migrate.go:64–78  ·  view source on GitHub ↗
(ctx context.Context, client *bigquery.Client, table string)

Source from the content-addressed store, hash-verified

62}
63
64func (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

Callers 3

MigrateTablesMethod · 0.95
waitForTableToExistMethod · 0.95
MigrateTablesMethod · 0.80

Calls 2

isAPINotFoundErrorFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected