|
36 | 36 | import io.airbyte.integrations.base.destination.typing_deduping.NoopTyperDeduper;
|
37 | 37 | import io.airbyte.integrations.base.destination.typing_deduping.NoopV2TableMigrator;
|
38 | 38 | import io.airbyte.integrations.base.destination.typing_deduping.ParsedCatalog;
|
| 39 | +import io.airbyte.integrations.base.destination.typing_deduping.SqlGenerator; |
39 | 40 | import io.airbyte.integrations.base.destination.typing_deduping.TyperDeduper;
|
| 41 | +import io.airbyte.integrations.base.destination.typing_deduping.migrators.Migration; |
40 | 42 | import io.airbyte.integrations.base.destination.typing_deduping.migrators.MinimumDestinationState;
|
41 | 43 | import io.airbyte.protocol.models.v0.AirbyteConnectionStatus;
|
42 | 44 | import io.airbyte.protocol.models.v0.AirbyteConnectionStatus.Status;
|
|
54 | 56 | import org.slf4j.Logger;
|
55 | 57 | import org.slf4j.LoggerFactory;
|
56 | 58 |
|
57 |
| -public abstract class AbstractJdbcDestination extends JdbcConnector implements Destination { |
| 59 | +public abstract class AbstractJdbcDestination<DestinationState extends MinimumDestinationState> |
| 60 | + extends JdbcConnector implements Destination { |
58 | 61 |
|
59 | 62 | private static final Logger LOGGER = LoggerFactory.getLogger(AbstractJdbcDestination.class);
|
60 | 63 |
|
@@ -254,9 +257,19 @@ private void assertCustomParametersDontOverwriteDefaultParameters(final Map<Stri
|
254 | 257 |
|
255 | 258 | protected abstract JdbcSqlGenerator getSqlGenerator();
|
256 | 259 |
|
257 |
| - protected abstract JdbcDestinationHandler<? extends MinimumDestinationState> getDestinationHandler(final String databaseName, |
258 |
| - final JdbcDatabase database, |
259 |
| - final String rawTableSchema); |
| 260 | + protected abstract JdbcDestinationHandler<DestinationState> getDestinationHandler(final String databaseName, |
| 261 | + final JdbcDatabase database, |
| 262 | + final String rawTableSchema); |
| 263 | + |
| 264 | + /** |
| 265 | + * Provide any migrations that the destination needs to run. Most destinations will need to provide an instande of |
| 266 | + * {@link io.airbyte.cdk.integrations.destination.jdbc.typing_deduping.JdbcV1V2Migrator} at minimum. |
| 267 | + */ |
| 268 | + protected abstract List<Migration<DestinationState>> getMigrations( |
| 269 | + final JdbcDatabase database, |
| 270 | + final String databaseName, |
| 271 | + final SqlGenerator sqlGenerator, |
| 272 | + final DestinationHandler<DestinationState> destinationHandler); |
260 | 273 |
|
261 | 274 | /**
|
262 | 275 | * "database" key at root of the config json, for any other variants in config, override this
|
@@ -321,15 +334,16 @@ private TyperDeduper getV2TyperDeduper(final JsonNode config, final ConfiguredAi
|
321 | 334 | final String databaseName = getDatabaseName(config);
|
322 | 335 | final var migrator = new JdbcV1V2Migrator(namingResolver, database, databaseName);
|
323 | 336 | final NoopV2TableMigrator v2TableMigrator = new NoopV2TableMigrator();
|
324 |
| - final DestinationHandler<? extends MinimumDestinationState> destinationHandler = |
| 337 | + final DestinationHandler<DestinationState> destinationHandler = |
325 | 338 | getDestinationHandler(databaseName, database, rawNamespaceOverride.orElse(DEFAULT_AIRBYTE_INTERNAL_NAMESPACE));
|
326 | 339 | final boolean disableTypeDedupe = config.has(DISABLE_TYPE_DEDUPE) && config.get(DISABLE_TYPE_DEDUPE).asBoolean(false);
|
327 | 340 | final TyperDeduper typerDeduper;
|
| 341 | + List<Migration<DestinationState>> migrations = getMigrations(database, databaseName, sqlGenerator, destinationHandler); |
328 | 342 | if (disableTypeDedupe) {
|
329 |
| - typerDeduper = new NoOpTyperDeduperWithV1V2Migrations<>(sqlGenerator, destinationHandler, parsedCatalog, migrator, v2TableMigrator, List.of()); |
| 343 | + typerDeduper = new NoOpTyperDeduperWithV1V2Migrations<>(sqlGenerator, destinationHandler, parsedCatalog, migrator, v2TableMigrator, migrations); |
330 | 344 | } else {
|
331 | 345 | typerDeduper =
|
332 |
| - new DefaultTyperDeduper<>(sqlGenerator, destinationHandler, parsedCatalog, migrator, v2TableMigrator, List.of()); |
| 346 | + new DefaultTyperDeduper<>(sqlGenerator, destinationHandler, parsedCatalog, migrator, v2TableMigrator, migrations); |
333 | 347 | }
|
334 | 348 | return typerDeduper;
|
335 | 349 | }
|
|
0 commit comments