Skip to content

Commit

Permalink
is this possible?
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Oct 12, 2024
1 parent 441bc75 commit 6bd61d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions flow/connectors/clickhouse/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
)

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

// getRawTableName returns the raw table name for the given table identifier.
Expand All @@ -36,6 +36,9 @@ func (c *ClickHouseConnector) checkIfTableExists(ctx context.Context, databaseNa
{Name: "table_exists", Data: &existsC},
},
OnResult: func(ctx context.Context, block chproto.Block) error {
if block.Rows == 0 && block.Info.Overflows {
return nil
}
if block.Rows != 1 {
return fmt.Errorf("[clickhouse] checkIfTableExists: expected 1 row, got %d", block.Rows)
}
Expand Down
3 changes: 1 addition & 2 deletions flow/connectors/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ func GetByNameAs[T Connector](ctx context.Context, env map[string]string, catalo
}

func CloseConnector(ctx context.Context, conn Connector) {
err := conn.Close()
if err != nil {
if err := conn.Close(); err != nil {
logger.LoggerFromCtx(ctx).Error("error closing connector", slog.Any("error", err))
}
}
Expand Down

0 comments on commit 6bd61d3

Please sign in to comment.