Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bigquery] Log if table name/dataset differ from expected #490

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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