Skip to content

Commit

Permalink
Tweak flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 16, 2024
1 parent 8770519 commit 5f3517e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions clients/redshift/staging.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ func (s *Store) PrepareTemporaryTable(ctx context.Context, tableData *optimizati
}

for colName, newValue := range colToNewLengthMap {
// Generate queries and then update the [tableConfig] with the new string precision.
if _, err = s.Exec(s.dialect().BuildIncreaseStringPrecisionQuery(parentTableID, colName, newValue)); err != nil {
return fmt.Errorf("failed to increase string precision for table %q: %w", parentTableID.FullyQualifiedName(), err)
}

// Try to upsert columns first. If this fails, we won't need to update the destination table.
err = tableConfig.Columns().UpsertColumn(colName, columns.UpsertColumnArg{
StringPrecision: typing.ToPtr(newValue),
})

if err != nil {
return fmt.Errorf("failed to update table config with new string precision: %w", err)
}

if _, err = s.Exec(s.dialect().BuildIncreaseStringPrecisionQuery(parentTableID, colName, newValue)); err != nil {
return fmt.Errorf("failed to increase string precision for table %q: %w", parentTableID.FullyQualifiedName(), err)
}
}

if createTempTable {
Expand Down

0 comments on commit 5f3517e

Please sign in to comment.