Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cynthiaxyin committed Sep 19, 2023
1 parent 68380cb commit 9f7565e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 228 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static java.util.stream.Collectors.joining;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import io.airbyte.integrations.base.JavaBaseConstants;
import io.airbyte.integrations.base.destination.typing_deduping.AirbyteProtocolType;
import io.airbyte.integrations.base.destination.typing_deduping.AirbyteType;
Expand All @@ -19,7 +20,6 @@
import io.airbyte.integrations.base.destination.typing_deduping.TableNotMigratedException;
import io.airbyte.integrations.base.destination.typing_deduping.Union;
import io.airbyte.integrations.base.destination.typing_deduping.UnsupportedOneOf;
import io.airbyte.integrations.destination.snowflake.SnowflakeReservedKeywords;
import io.airbyte.protocol.models.v0.DestinationSyncMode;
import java.util.Arrays;
import java.util.LinkedHashMap;
Expand All @@ -35,6 +35,16 @@ public class SnowflakeSqlGenerator implements SqlGenerator<SnowflakeTableDefinit

private final ColumnId CDC_DELETED_AT_COLUMN = buildColumnId("_ab_cdc_deleted_at");

// See https://docs.snowflake.com/en/sql-reference/reserved-keywords.html
// and https://github.com/airbytehq/airbyte/blob/f226503bd1d4cd9c7412b04d47de584523988443/airbyte-integrations/bases/base-normalization/normalization/transform_catalog/reserved_keywords.py
private static final List<String> RESERVED_COLUMN_NAMES = ImmutableList.of(
"CURRENT_DATE",
"CURRENT_TIME",
"CURRENT_TIMESTAMP",
"CURRENT_USER",
"LOCALTIME",
"LOCALTIMESTAMP");

@Override
public StreamId buildStreamId(final String namespace, final String name, final String rawNamespaceOverride) {
// No escaping needed, as far as I can tell. We quote all our identifier names.
Expand Down Expand Up @@ -582,7 +592,7 @@ public static String escapeSqlIdentifier(String identifier) {
}

private static String prefixReservedColumnName(final String columnName) {
return SnowflakeReservedKeywords.RESERVED_COLUMN_NAMES.stream().anyMatch(k -> k.equalsIgnoreCase(columnName)) ?
return RESERVED_COLUMN_NAMES.stream().anyMatch(k -> k.equalsIgnoreCase(columnName)) ?
"_" + columnName : columnName;
}

Expand Down

0 comments on commit 9f7565e

Please sign in to comment.