Skip to content

Commit

Permalink
quote table names (#2234)
Browse files Browse the repository at this point in the history
Co-authored-by: Philip Dubé <[email protected]>
  • Loading branch information
iskakaushik and serprex authored Nov 9, 2024
1 parent e05ce07 commit 0fa358b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion flow/connectors/clickhouse/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (c *ClickHouseConnector) ReplayTableSchemaDeltas(ctx context.Context, flowJ
return fmt.Errorf("failed to convert column type %s to ClickHouse type: %w", addedColumn.Type, err)
}
err = c.execWithLogging(ctx,
fmt.Sprintf("ALTER TABLE %s ADD COLUMN IF NOT EXISTS \"%s\" %s",
fmt.Sprintf("ALTER TABLE `%s` ADD COLUMN IF NOT EXISTS `%s` %s",
schemaDelta.DstTableName, addedColumn.Name, clickHouseColType))
if err != nil {
return fmt.Errorf("failed to add column %s for table %s: %w", addedColumn.Name, schemaDelta.DstTableName, err)
Expand Down
6 changes: 3 additions & 3 deletions flow/connectors/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,21 @@ func (c *ClickHouseConnector) ValidateCheck(ctx context.Context) error {

// add a column
if err := c.exec(ctx,
fmt.Sprintf("ALTER TABLE %s ADD COLUMN updated_at DateTime64(9) DEFAULT now64()", validateDummyTableName),
fmt.Sprintf("ALTER TABLE `%s` ADD COLUMN updated_at DateTime64(9) DEFAULT now64()", validateDummyTableName),
); err != nil {
return fmt.Errorf("failed to add column to validation table %s: %w", validateDummyTableName, err)
}

// rename the table
if err := c.exec(ctx,
fmt.Sprintf("RENAME TABLE %s TO %s", validateDummyTableName, validateDummyTableName+"_renamed"),
fmt.Sprintf("RENAME TABLE `%s` TO `%s`", validateDummyTableName, validateDummyTableName+"_renamed"),
); err != nil {
return fmt.Errorf("failed to rename validation table %s: %w", validateDummyTableName, err)
}
validateDummyTableName += "_renamed"

// insert a row
if err := c.exec(ctx, fmt.Sprintf("INSERT INTO %s VALUES (1, now64())", validateDummyTableName)); err != nil {
if err := c.exec(ctx, fmt.Sprintf("INSERT INTO `%s` VALUES (1, now64())", validateDummyTableName)); err != nil {
return fmt.Errorf("failed to insert into validation table %s: %w", validateDummyTableName, err)
}

Expand Down

0 comments on commit 0fa358b

Please sign in to comment.