Skip to content

Commit

Permalink
[bigquery] Log if table name/dataset differ from expected (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie authored Apr 23, 2024
1 parent 1b4d56f commit 2108647
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions clients/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,35 @@ func tableRelName(fqName string) (string, error) {
}

func (s *Store) putTable(ctx context.Context, dataset string, tableID types.TableIdentifier, rows []*Row) error {
// TODO: [tableID] has [Dataset] on it, don't need to pass it along.
bqTableID, ok := tableID.(TableIdentifier)
if !ok {
return fmt.Errorf("unable to cast tableID to BigQuery TableIdentifier")
}

tableName := tableID.FullyQualifiedName()
// TODO: Can probably do `tableName := tableID.Table()` here.
relTableName, err := tableRelName(tableName)
if err != nil {
return fmt.Errorf("failed to get table name: %w", err)
}

if dataset != bqTableID.Dataset() {
// TODO: [tableID] has [Dataset] on it, don't need to pass it along.
slog.Error("BigQuery dataset is different",
slog.String("dataset", dataset),
slog.String("bqTableID.Dataset", bqTableID.Dataset()),
slog.String("fqn", tableName),
)
}

if relTableName != bqTableID.Table() {
// TODO: Use [bqTableID.Table] instead of [relTableName].
slog.Error("BigQuery table name is different",
slog.String("relTableName", relTableName),
slog.String("bqTableID.Table", bqTableID.Table()),
slog.String("fqn", tableName),
)
}

client := s.GetClient(ctx)
defer client.Close()

Expand Down

0 comments on commit 2108647

Please sign in to comment.