diff --git a/airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/base/JavaBaseConstants.java b/airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/base/JavaBaseConstants.java index 97b611cb7d60..62b852b07075 100644 --- a/airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/base/JavaBaseConstants.java +++ b/airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/base/JavaBaseConstants.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Set; +import org.apache.commons.lang3.StringUtils; public final class JavaBaseConstants { @@ -53,4 +54,8 @@ private JavaBaseConstants() {} public static final String DEFAULT_AIRBYTE_INTERNAL_NAMESPACE = "airbyte_internal"; + public static String upperQuoted(final String column) { + return StringUtils.wrap(column.toUpperCase(), "\""); + } + } diff --git a/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties b/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties index 31662eadd539..9bc3c7b294e6 100644 --- a/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties +++ b/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties @@ -1 +1 @@ -version=0.24.0 +version=0.24.1 diff --git a/airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/java/io/airbyte/cdk/integrations/destination/jdbc/AbstractJdbcDestination.java b/airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/java/io/airbyte/cdk/integrations/destination/jdbc/AbstractJdbcDestination.java index 03eb3203794f..2c76043c42bf 100644 --- a/airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/java/io/airbyte/cdk/integrations/destination/jdbc/AbstractJdbcDestination.java +++ b/airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/java/io/airbyte/cdk/integrations/destination/jdbc/AbstractJdbcDestination.java @@ -80,6 +80,16 @@ protected String getConfigSchemaKey() { return "schema"; } + /** + * If the destination should always disable type dedupe, override this method to return true. We + * only type and dedupe if we create final tables. + * + * @return whether the destination should always disable type dedupe + */ + protected boolean shouldAlwaysDisableTypeDedupe() { + return false; + } + public AbstractJdbcDestination(final String driverClass, final NamingConventionTransformer namingResolver, final SqlOperations sqlOperations) { @@ -317,6 +327,10 @@ public SerializedAirbyteMessageConsumer getSerializedMessageConsumer(final JsonN typerDeduper); } + private boolean isTypeDedupeDisabled(final JsonNode config) { + return shouldAlwaysDisableTypeDedupe() || (config.has(DISABLE_TYPE_DEDUPE) && config.get(DISABLE_TYPE_DEDUPE).asBoolean(false)); + } + /** * Creates the appropriate TyperDeduper class for the jdbc destination and the user's configuration * @@ -337,7 +351,7 @@ private TyperDeduper getV2TyperDeduper(final JsonNode config, final ConfiguredAi final NoopV2TableMigrator v2TableMigrator = new NoopV2TableMigrator(); final DestinationHandler destinationHandler = getDestinationHandler(databaseName, database, rawNamespaceOverride.orElse(DEFAULT_AIRBYTE_INTERNAL_NAMESPACE)); - final boolean disableTypeDedupe = config.has(DISABLE_TYPE_DEDUPE) && config.get(DISABLE_TYPE_DEDUPE).asBoolean(false); + final boolean disableTypeDedupe = isTypeDedupeDisabled(config); final TyperDeduper typerDeduper; List> migrations = getMigrations(database, databaseName, sqlGenerator, destinationHandler); if (disableTypeDedupe) { diff --git a/airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/java/io/airbyte/cdk/integrations/destination/jdbc/typing_deduping/NoOpJdbcDestinationHandler.kt b/airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/java/io/airbyte/cdk/integrations/destination/jdbc/typing_deduping/NoOpJdbcDestinationHandler.kt new file mode 100644 index 000000000000..5e5edb140de1 --- /dev/null +++ b/airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/java/io/airbyte/cdk/integrations/destination/jdbc/typing_deduping/NoOpJdbcDestinationHandler.kt @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Airbyte, Inc., all rights reserved. + */ + +package io.airbyte.cdk.integrations.destination.jdbc.typing_deduping + +import com.fasterxml.jackson.databind.JsonNode +import io.airbyte.cdk.db.jdbc.JdbcDatabase +import io.airbyte.cdk.integrations.destination.jdbc.TableDefinition +import io.airbyte.integrations.base.destination.typing_deduping.AirbyteType +import io.airbyte.integrations.base.destination.typing_deduping.Sql +import io.airbyte.integrations.base.destination.typing_deduping.StreamConfig +import org.jooq.SQLDialect + +class NoOpJdbcDestinationHandler( + databaseName: String, + jdbcDatabase: JdbcDatabase, + rawTableSchemaName: String, + sqlDialect: SQLDialect +) : + JdbcDestinationHandler( + databaseName, + jdbcDatabase, + rawTableSchemaName, + sqlDialect + ) { + override fun execute(sql: Sql?) { + throw NotImplementedError("This JDBC Destination Handler does not support typing deduping") + } + + override fun toDestinationState(json: JsonNode?): DestinationState { + throw NotImplementedError("This JDBC Destination Handler does not support typing deduping") + } + + override fun existingSchemaMatchesStreamConfig( + stream: StreamConfig?, + existingTable: TableDefinition? + ): Boolean { + throw NotImplementedError("This JDBC Destination Handler does not support typing deduping") + } + + override fun toJdbcTypeName(airbyteType: AirbyteType?): String { + throw NotImplementedError("This JDBC Destination Handler does not support typing deduping") + } +}