From 441bc7557551d70b75140f11388646aff39bb013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Sat, 12 Oct 2024 14:40:23 +0000 Subject: [PATCH] not sure why exists is uint8 instead of bool, but ok --- flow/connectors/clickhouse/cdc.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/flow/connectors/clickhouse/cdc.go b/flow/connectors/clickhouse/cdc.go index f09dcff9aa..d8067f2d58 100644 --- a/flow/connectors/clickhouse/cdc.go +++ b/flow/connectors/clickhouse/cdc.go @@ -2,6 +2,7 @@ package connclickhouse import ( "context" + "errors" "fmt" "log/slog" "strings" @@ -28,7 +29,7 @@ func (c *ClickHouseConnector) getRawTableName(flowJobName string) string { func (c *ClickHouseConnector) checkIfTableExists(ctx context.Context, databaseName string, tableIdentifier string) (bool, error) { // TODO escape - var existsC chproto.ColBool + var existsC chproto.ColUInt8 if err := c.query(ctx, ch.Query{ Body: fmt.Sprintf(checkIfTableExistsSQL, "'"+databaseName+"'", "'"+tableIdentifier+"'"), Result: chproto.Results{ @@ -38,12 +39,15 @@ func (c *ClickHouseConnector) checkIfTableExists(ctx context.Context, databaseNa if block.Rows != 1 { return fmt.Errorf("[clickhouse] checkIfTableExists: expected 1 row, got %d", block.Rows) } + if block.Info.Overflows { + return errors.New("[clickhouse] checkIfTableExists: expected 1 row, got block with overflow") + } return nil }, }); err != nil { return false, fmt.Errorf("error while reading result row: %w", err) } - return existsC[0], nil + return existsC[0] != 0, nil } func (c *ClickHouseConnector) CreateRawTable(ctx context.Context, req *protos.CreateRawTableInput) (*protos.CreateRawTableOutput, error) {