From 73a7409417138c79ee23e0b1644f956cbf1b42db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Wed, 14 Feb 2024 03:35:45 +0000 Subject: [PATCH] raw table names: preserve underscores in names avoids mirror a__b from having a name conflict with a_b --- flow/connectors/bigquery/bigquery.go | 2 +- flow/connectors/clickhouse/cdc.go | 2 +- flow/connectors/postgres/client.go | 2 +- flow/connectors/snowflake/snowflake.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flow/connectors/bigquery/bigquery.go b/flow/connectors/bigquery/bigquery.go index 438994a800..4d63a97657 100644 --- a/flow/connectors/bigquery/bigquery.go +++ b/flow/connectors/bigquery/bigquery.go @@ -793,7 +793,7 @@ func (c *BigQueryConnector) SyncFlowCleanup(ctx context.Context, jobName string) // getRawTableName returns the raw table name for the given table identifier. func (c *BigQueryConnector) getRawTableName(flowJobName string) string { // replace all non-alphanumeric characters with _ - flowJobName = regexp.MustCompile("[^a-zA-Z0-9]+").ReplaceAllString(flowJobName, "_") + flowJobName = regexp.MustCompile("[^a-zA-Z0-9_]+").ReplaceAllString(flowJobName, "_") return fmt.Sprintf("_peerdb_raw_%s", flowJobName) } diff --git a/flow/connectors/clickhouse/cdc.go b/flow/connectors/clickhouse/cdc.go index 8e2a48a877..24c9a8f0f5 100644 --- a/flow/connectors/clickhouse/cdc.go +++ b/flow/connectors/clickhouse/cdc.go @@ -24,7 +24,7 @@ const ( // getRawTableName returns the raw table name for the given table identifier. func (c *ClickhouseConnector) getRawTableName(flowJobName string) string { // replace all non-alphanumeric characters with _ - flowJobName = regexp.MustCompile("[^a-zA-Z0-9]+").ReplaceAllString(flowJobName, "_") + flowJobName = regexp.MustCompile("[^a-zA-Z0-9_]+").ReplaceAllString(flowJobName, "_") return fmt.Sprintf("_peerdb_raw_%s", flowJobName) } diff --git a/flow/connectors/postgres/client.go b/flow/connectors/postgres/client.go index 333f0516a4..72a5691fe5 100644 --- a/flow/connectors/postgres/client.go +++ b/flow/connectors/postgres/client.go @@ -425,7 +425,7 @@ func (c *PostgresConnector) createMetadataSchema(ctx context.Context) error { } func getRawTableIdentifier(jobName string) string { - jobName = regexp.MustCompile("[^a-zA-Z0-9]+").ReplaceAllString(jobName, "_") + jobName = regexp.MustCompile("[^a-zA-Z0-9_]+").ReplaceAllString(jobName, "_") return fmt.Sprintf("%s_%s", rawTablePrefix, strings.ToLower(jobName)) } diff --git a/flow/connectors/snowflake/snowflake.go b/flow/connectors/snowflake/snowflake.go index 1644787119..cb86bc4389 100644 --- a/flow/connectors/snowflake/snowflake.go +++ b/flow/connectors/snowflake/snowflake.go @@ -724,7 +724,7 @@ func generateCreateTableSQLForNormalizedTable( } func getRawTableIdentifier(jobName string) string { - jobName = regexp.MustCompile("[^a-zA-Z0-9]+").ReplaceAllString(jobName, "_") + jobName = regexp.MustCompile("[^a-zA-Z0-9_]+").ReplaceAllString(jobName, "_") return fmt.Sprintf("%s_%s", rawTablePrefix, jobName) }