Skip to content

Commit

Permalink
Move defer up
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Jun 18, 2024
1 parent d39e66f commit ab80577
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clients/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func (s *Store) Append(tableData *optimization.TableData, useTempTable bool) err
// For now, we'll need to append this to a temporary table and then append temporary table onto the target table
tableID := s.IdentifierFor(tableData.TopicConfig(), tableData.Name())
temporaryTableID := shared.TempTableID(tableID)

defer func() { _ = ddl.DropTemporaryTable(s, temporaryTableID, false) }()

err := shared.Append(s, tableData, types.AdditionalSettings{
UseTempTable: true,
TempTableID: temporaryTableID,
Expand All @@ -64,8 +67,6 @@ func (s *Store) Append(tableData *optimization.TableData, useTempTable bool) err
return fmt.Errorf("failed to append: %w", err)
}

defer func() { _ = ddl.DropTemporaryTable(s, temporaryTableID, false) }()

if _, err = s.Exec(
fmt.Sprintf(`INSERT INTO %s SELECT * FROM %s`, tableID.FullyQualifiedName(), temporaryTableID.FullyQualifiedName()),
); err != nil {
Expand Down

0 comments on commit ab80577

Please sign in to comment.