From 373bfb2621765dd95c7003b943bc0fd734eac36e Mon Sep 17 00:00:00 2001 From: Amogh Bharadwaj Date: Thu, 7 Mar 2024 01:58:41 +0530 Subject: [PATCH] Clickhouse: specify columns more in insert select (#1442) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR is an attempt to fix #1439 , by explicitly specifying the columns in `select * from s3(...)` in Qrep for Clickhouse. Functionally tested Co-authored-by: Philip Dubé --- flow/connectors/clickhouse/qrep_avro_sync.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flow/connectors/clickhouse/qrep_avro_sync.go b/flow/connectors/clickhouse/qrep_avro_sync.go index f4631ca4f4..2a6d1f217e 100644 --- a/flow/connectors/clickhouse/qrep_avro_sync.go +++ b/flow/connectors/clickhouse/qrep_avro_sync.go @@ -130,12 +130,12 @@ func (s *ClickhouseAvroSyncMethod) SyncQRepRecords( continue } - selector = append(selector, colName) + selector = append(selector, "`"+colName+"`") } selectorStr := strings.Join(selector, ",") //nolint:gosec - query := fmt.Sprintf("INSERT INTO %s(%s) SELECT * FROM s3('%s','%s','%s', 'Avro')", - config.DestinationTableIdentifier, selectorStr, avroFileUrl, + query := fmt.Sprintf("INSERT INTO %s(%s) SELECT %s FROM s3('%s','%s','%s', 'Avro')", + config.DestinationTableIdentifier, selectorStr, selectorStr, avroFileUrl, s.connector.creds.AccessKeyID, s.connector.creds.SecretAccessKey) _, err = s.connector.database.ExecContext(ctx, query)