Skip to content

Commit

Permalink
Adding more logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Dec 17, 2024
1 parent b0fce89 commit 56ade28
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion clients/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func (s *Store) putTable(ctx context.Context, bqTableID dialect.TableIdentifier,
if err != nil {
return fmt.Errorf("failed to create managedwriter client: %w", err)
}

defer managedWriterClient.Close()

managedStream, err := managedWriterClient.NewManagedStream(ctx,
Expand All @@ -161,6 +162,7 @@ func (s *Store) putTable(ctx context.Context, bqTableID dialect.TableIdentifier,
if err != nil {
return fmt.Errorf("failed to create managed stream: %w", err)
}

defer managedStream.Close()

encoder := func(row map[string]any) ([]byte, error) {
Expand All @@ -183,10 +185,15 @@ func (s *Store) putTable(ctx context.Context, bqTableID dialect.TableIdentifier,
return fmt.Errorf("failed to append rows: %w", err)
}

if resp, err := result.FullResponse(ctx); err != nil {
resp, err := result.FullResponse(ctx)
if err != nil {
return fmt.Errorf("failed to get response (%s): %w", resp.GetError().String(), err)
}

if status := resp.GetError(); status != nil {
return fmt.Errorf("failed to append rows: %s", status.String())
}

return nil
})
}
Expand Down

0 comments on commit 56ade28

Please sign in to comment.