@@ -83,10 +83,9 @@ func NewBigQueryConnector(ctx context.Context, config *protos.BigqueryConfig) (*
8383 return nil , fmt .Errorf ("failed to create BigQuery client: %v" , err )
8484 }
8585
86- _ , datasetErr := client .DatasetInProject (projectID , datasetID ).Metadata (ctx )
87- if datasetErr != nil {
88- logger .Error ("failed to get dataset metadata" , "error" , datasetErr )
89- return nil , fmt .Errorf ("failed to get dataset metadata: %v" , datasetErr )
86+ if _ , err := client .DatasetInProject (projectID , datasetID ).Metadata (ctx ); err != nil {
87+ logger .Error ("failed to get dataset metadata" , "error" , err )
88+ return nil , fmt .Errorf ("failed to get dataset metadata: %v" , err )
9089 }
9190
9291 storageClient , err := bqsa .CreateStorageClient (ctx )
@@ -166,8 +165,7 @@ func (c *BigQueryConnector) Close() error {
166165
167166// ConnectionActive returns nil if the connection is active.
168167func (c * BigQueryConnector ) ConnectionActive (ctx context.Context ) error {
169- _ , err := c .client .DatasetInProject (c .projectID , c .datasetID ).Metadata (ctx )
170- if err != nil {
168+ if _ , err := c .client .DatasetInProject (c .projectID , c .datasetID ).Metadata (ctx ); err != nil {
171169 return fmt .Errorf ("failed to get dataset metadata: %v" , err )
172170 }
173171
@@ -182,12 +180,13 @@ func (c *BigQueryConnector) waitForTableReady(ctx context.Context, datasetTable
182180 attempt := 0
183181
184182 for {
183+ if err := ctx .Err (); err != nil {
184+ return err
185+ }
185186 if time .Now ().After (deadline ) {
186187 return fmt .Errorf ("timeout reached while waiting for table %s to be ready" , datasetTable )
187188 }
188-
189- _ , err := table .Metadata (ctx )
190- if err == nil {
189+ if _ , err := table .Metadata (ctx ); err == nil {
191190 return nil
192191 }
193192
@@ -768,8 +767,7 @@ func (c *BigQueryConnector) RenameTables(
768767
769768 // if _resync table does not exist, log and continue.
770769 dataset := c .client .DatasetInProject (c .projectID , srcDatasetTable .dataset )
771- _ , err := dataset .Table (srcDatasetTable .table ).Metadata (ctx )
772- if err != nil {
770+ if _ , err := dataset .Table (srcDatasetTable .table ).Metadata (ctx ); err != nil {
773771 if ! strings .Contains (err .Error (), "notFound" ) {
774772 return nil , fmt .Errorf ("[renameTable] failed to get metadata for _resync table %s: %w" , srcDatasetTable .string (), err )
775773 }
@@ -779,8 +777,7 @@ func (c *BigQueryConnector) RenameTables(
779777
780778 // if the original table does not exist, log and skip soft delete step
781779 originalTableExists := true
782- _ , err = dataset .Table (dstDatasetTable .table ).Metadata (ctx )
783- if err != nil {
780+ if _ , err := dataset .Table (dstDatasetTable .table ).Metadata (ctx ); err != nil {
784781 if ! strings .Contains (err .Error (), "notFound" ) {
785782 return nil , fmt .Errorf ("[renameTable] failed to get metadata for original table %s: %w" , dstDatasetTable .string (), err )
786783 }
@@ -860,8 +857,7 @@ func (c *BigQueryConnector) RenameTables(
860857
861858 query .DefaultProjectID = c .projectID
862859 query .DefaultDatasetID = c .datasetID
863- _ , err := query .Read (ctx )
864- if err != nil {
860+ if _ , err := query .Read (ctx ); err != nil {
865861 return nil , fmt .Errorf ("unable to handle soft-deletes for table %s: %w" , dstDatasetTable .string (), err )
866862 }
867863 }
@@ -876,8 +872,7 @@ func (c *BigQueryConnector) RenameTables(
876872
877873 query .DefaultProjectID = c .projectID
878874 query .DefaultDatasetID = c .datasetID
879- _ , err := query .Read (ctx )
880- if err != nil {
875+ if _ , err := query .Read (ctx ); err != nil {
881876 return nil , fmt .Errorf ("unable to set synced at column for table %s: %w" , srcDatasetTable .string (), err )
882877 }
883878 }
@@ -886,8 +881,7 @@ func (c *BigQueryConnector) RenameTables(
886881 dropQuery := c .queryWithLogging ("DROP TABLE IF EXISTS " + dstDatasetTable .string ())
887882 dropQuery .DefaultProjectID = c .projectID
888883 dropQuery .DefaultDatasetID = c .datasetID
889- _ , err = dropQuery .Read (ctx )
890- if err != nil {
884+ if _ , err := dropQuery .Read (ctx ); err != nil {
891885 return nil , fmt .Errorf ("unable to drop table %s: %w" , dstDatasetTable .string (), err )
892886 }
893887
@@ -896,8 +890,7 @@ func (c *BigQueryConnector) RenameTables(
896890 srcDatasetTable .string (), dstDatasetTable .table ))
897891 query .DefaultProjectID = c .projectID
898892 query .DefaultDatasetID = c .datasetID
899- _ , err = query .Read (ctx )
900- if err != nil {
893+ if _ , err := query .Read (ctx ); err != nil {
901894 return nil , fmt .Errorf ("unable to rename table %s to %s: %w" , srcDatasetTable .string (),
902895 dstDatasetTable .string (), err )
903896 }
@@ -925,8 +918,7 @@ func (c *BigQueryConnector) CreateTablesFromExisting(
925918 newDatasetTable .string (), existingDatasetTable .string ()))
926919 query .DefaultProjectID = c .projectID
927920 query .DefaultDatasetID = c .datasetID
928- _ , err := query .Read (ctx )
929- if err != nil {
921+ if _ , err := query .Read (ctx ); err != nil {
930922 return nil , fmt .Errorf ("unable to create table %s: %w" , newTable , err )
931923 }
932924
@@ -950,8 +942,7 @@ func (c *BigQueryConnector) RemoveTableEntriesFromRawTable(
950942 rawTableIdentifier , tableName , req .NormalizeBatchId , req .SyncBatchId ))
951943 deleteCmd .DefaultProjectID = c .projectID
952944 deleteCmd .DefaultDatasetID = c .datasetID
953- _ , err := deleteCmd .Read (ctx )
954- if err != nil {
945+ if _ , err := deleteCmd .Read (ctx ); err != nil {
955946 c .logger .Error ("failed to remove entries from raw table" , "error" , err )
956947 }
957948
0 commit comments