Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Jan 23, 2025
1 parent 36307ea commit 2a25163
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions models/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,10 @@ func (e *Event) Save(cfg config.Config, inMemDB *models.DatabaseData, tc kafkali
// Update col if necessary
sanitizedData := make(map[string]any)
for _col, val := range e.Data {
// TODO: Refactor this to call columns.EscapeName(...)
// columns need to all be normalized and lower cased.
newColName := strings.ToLower(_col)
// Columns here could contain spaces. Every destination treats spaces in a column differently.
// So far, Snowflake accepts them when escaped properly, however BigQuery does not accept it.
// Instead of making this more complicated for future destinations, we will escape the spaces by having double underscore `__`
// So, if customers want to retrieve spaces again, they can replace `__`.
var containsSpace bool
containsSpace, newColName = stringutil.EscapeSpaces(newColName)
if containsSpace {
// Write the message back if the column has changed.
newColName := columns.EscapeName(_col)
if newColName != _col {
// This means that the column name has changed.
// We need to update the column name in the sanitizedData map.
sanitizedData[newColName] = val
}

Expand Down

0 comments on commit 2a25163

Please sign in to comment.