|
4 | 4 |
|
5 | 5 | package io.airbyte.cdk.integrations.destination.jdbc;
|
6 | 6 |
|
| 7 | +import static io.airbyte.cdk.integrations.base.JavaBaseConstants.DEFAULT_AIRBYTE_INTERNAL_NAMESPACE; |
7 | 8 | import static io.airbyte.cdk.integrations.base.errors.messages.ErrorMessage.getErrorMessage;
|
8 | 9 | import static io.airbyte.cdk.integrations.util.ConfiguredCatalogUtilKt.addDefaultNamespaceToStreams;
|
9 | 10 |
|
|
17 | 18 | import io.airbyte.cdk.integrations.base.AirbyteMessageConsumer;
|
18 | 19 | import io.airbyte.cdk.integrations.base.AirbyteTraceMessageUtility;
|
19 | 20 | import io.airbyte.cdk.integrations.base.Destination;
|
20 |
| -import io.airbyte.cdk.integrations.base.JavaBaseConstants; |
21 | 21 | import io.airbyte.cdk.integrations.base.SerializedAirbyteMessageConsumer;
|
22 | 22 | import io.airbyte.cdk.integrations.base.TypingAndDedupingFlag;
|
23 | 23 | import io.airbyte.cdk.integrations.destination.NamingConventionTransformer;
|
|
37 | 37 | import io.airbyte.integrations.base.destination.typing_deduping.NoopV2TableMigrator;
|
38 | 38 | import io.airbyte.integrations.base.destination.typing_deduping.ParsedCatalog;
|
39 | 39 | import io.airbyte.integrations.base.destination.typing_deduping.TyperDeduper;
|
| 40 | +import io.airbyte.integrations.base.destination.typing_deduping.migrators.MinimumDestinationState; |
40 | 41 | import io.airbyte.protocol.models.v0.AirbyteConnectionStatus;
|
41 | 42 | import io.airbyte.protocol.models.v0.AirbyteConnectionStatus.Status;
|
42 | 43 | import io.airbyte.protocol.models.v0.AirbyteMessage;
|
|
45 | 46 | import java.util.List;
|
46 | 47 | import java.util.Map;
|
47 | 48 | import java.util.Objects;
|
| 49 | +import java.util.Optional; |
48 | 50 | import java.util.UUID;
|
49 | 51 | import java.util.function.Consumer;
|
50 | 52 | import javax.sql.DataSource;
|
@@ -93,7 +95,7 @@ public AirbyteConnectionStatus check(final JsonNode config) {
|
93 | 95 | attemptTableOperations(outputSchema, database, namingResolver, sqlOperations, false);
|
94 | 96 | if (TypingAndDedupingFlag.isDestinationV2()) {
|
95 | 97 | final var v2RawSchema = namingResolver.getIdentifier(TypingAndDedupingFlag.getRawNamespaceOverride(RAW_SCHEMA_OVERRIDE)
|
96 |
| - .orElse(JavaBaseConstants.DEFAULT_AIRBYTE_INTERNAL_NAMESPACE)); |
| 98 | + .orElse(DEFAULT_AIRBYTE_INTERNAL_NAMESPACE)); |
97 | 99 | attemptTableOperations(v2RawSchema, database, namingResolver, sqlOperations, false);
|
98 | 100 | destinationSpecificTableOperations(database);
|
99 | 101 | }
|
@@ -252,7 +254,9 @@ private void assertCustomParametersDontOverwriteDefaultParameters(final Map<Stri
|
252 | 254 |
|
253 | 255 | protected abstract JdbcSqlGenerator getSqlGenerator();
|
254 | 256 |
|
255 |
| - protected abstract JdbcDestinationHandler getDestinationHandler(final String databaseName, final JdbcDatabase database); |
| 257 | + protected abstract JdbcDestinationHandler<? extends MinimumDestinationState> getDestinationHandler(final String databaseName, |
| 258 | + final JdbcDatabase database, |
| 259 | + final String rawTableSchema); |
256 | 260 |
|
257 | 261 | /**
|
258 | 262 | * "database" key at root of the config json, for any other variants in config, override this
|
@@ -309,21 +313,23 @@ public SerializedAirbyteMessageConsumer getSerializedMessageConsumer(final JsonN
|
309 | 313 | */
|
310 | 314 | private TyperDeduper getV2TyperDeduper(final JsonNode config, final ConfiguredAirbyteCatalog catalog, final JdbcDatabase database) {
|
311 | 315 | final JdbcSqlGenerator sqlGenerator = getSqlGenerator();
|
312 |
| - final ParsedCatalog parsedCatalog = TypingAndDedupingFlag.getRawNamespaceOverride(RAW_SCHEMA_OVERRIDE) |
| 316 | + Optional<String> rawNamespaceOverride = TypingAndDedupingFlag.getRawNamespaceOverride(RAW_SCHEMA_OVERRIDE); |
| 317 | + final ParsedCatalog parsedCatalog = rawNamespaceOverride |
313 | 318 | .map(override -> new CatalogParser(sqlGenerator, override))
|
314 | 319 | .orElse(new CatalogParser(sqlGenerator))
|
315 | 320 | .parseCatalog(catalog);
|
316 | 321 | final String databaseName = getDatabaseName(config);
|
317 | 322 | final var migrator = new JdbcV1V2Migrator(namingResolver, database, databaseName);
|
318 | 323 | final NoopV2TableMigrator v2TableMigrator = new NoopV2TableMigrator();
|
319 |
| - final DestinationHandler destinationHandler = getDestinationHandler(databaseName, database); |
| 324 | + final DestinationHandler<? extends MinimumDestinationState> destinationHandler = |
| 325 | + getDestinationHandler(databaseName, database, rawNamespaceOverride.orElse(DEFAULT_AIRBYTE_INTERNAL_NAMESPACE)); |
320 | 326 | final boolean disableTypeDedupe = config.has(DISABLE_TYPE_DEDUPE) && config.get(DISABLE_TYPE_DEDUPE).asBoolean(false);
|
321 | 327 | final TyperDeduper typerDeduper;
|
322 | 328 | if (disableTypeDedupe) {
|
323 |
| - typerDeduper = new NoOpTyperDeduperWithV1V2Migrations(sqlGenerator, destinationHandler, parsedCatalog, migrator, v2TableMigrator); |
| 329 | + typerDeduper = new NoOpTyperDeduperWithV1V2Migrations<>(sqlGenerator, destinationHandler, parsedCatalog, migrator, v2TableMigrator, List.of()); |
324 | 330 | } else {
|
325 | 331 | typerDeduper =
|
326 |
| - new DefaultTyperDeduper(sqlGenerator, destinationHandler, parsedCatalog, migrator, v2TableMigrator); |
| 332 | + new DefaultTyperDeduper<>(sqlGenerator, destinationHandler, parsedCatalog, migrator, v2TableMigrator, List.of()); |
327 | 333 | }
|
328 | 334 | return typerDeduper;
|
329 | 335 | }
|
|
0 commit comments