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

Clean up BackfillColumn #569

Merged
merged 1 commit into from
May 4, 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
10 changes: 1 addition & 9 deletions clients/shared/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,9 @@ func BackfillColumn(cfg config.Config, dwh destination.DataWarehouse, column col

escapedCol := dwh.Dialect().QuoteIdentifier(column.Name())

// TODO: This is added because `default` is not technically a column that requires escaping, but it is required when it's in the where clause.
// Once we escape everything by default, we can remove this patch of code.
additionalEscapedCol := escapedCol
if additionalEscapedCol == "default" && dwh.Label() == constants.Snowflake {
// It should be uppercase because Snowflake's default column is uppercase and since it's not a reserved column name, it uses the default setting.
additionalEscapedCol = `"DEFAULT"`
}

query := fmt.Sprintf(`UPDATE %s SET %s = %v WHERE %s IS NULL;`,
// UPDATE table SET col = default_val WHERE col IS NULL
tableID.FullyQualifiedName(), escapedCol, defaultVal, additionalEscapedCol,
tableID.FullyQualifiedName(), escapedCol, defaultVal, escapedCol,
)
slog.Info("Backfilling column",
slog.String("colName", column.Name()),
Expand Down