Skip to content

Commit

Permalink
quote table names for drop,fallback rename (#2235)
Browse files Browse the repository at this point in the history
  • Loading branch information
heavycrystal authored Nov 8, 2024
1 parent 5f431bb commit e05ce07
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flow/connectors/clickhouse/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

const (
checkIfTableExistsSQL = `SELECT exists(SELECT 1 FROM system.tables WHERE database = ? AND name = ?) AS table_exists;`
dropTableIfExistsSQL = `DROP TABLE IF EXISTS %s;`
dropTableIfExistsSQL = "DROP TABLE IF EXISTS `%s`;"
)

// getRawTableName returns the raw table name for the given table identifier.
Expand Down Expand Up @@ -215,7 +215,7 @@ func (c *ClickHouseConnector) RenameTables(
}

if err := c.execWithLogging(ctx,
fmt.Sprintf("RENAME TABLE %s TO %s", renameRequest.CurrentName, renameRequest.NewName),
fmt.Sprintf("RENAME TABLE `%s` TO `%s`", renameRequest.CurrentName, renameRequest.NewName),
); err != nil {
return nil, fmt.Errorf("unable to rename table %s to %s: %w", renameRequest.CurrentName, renameRequest.NewName, err)
}
Expand Down

0 comments on commit e05ce07

Please sign in to comment.