Skip to content

Commit

Permalink
improve should use cdc check
Browse files Browse the repository at this point in the history
  • Loading branch information
subodh1810 committed Jun 22, 2022
1 parent 24d7fa8 commit 7d01727
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import io.airbyte.integrations.debezium.internals.FilteredFileDatabaseHistory;
import io.airbyte.protocol.models.AirbyteMessage;
import io.airbyte.protocol.models.ConfiguredAirbyteCatalog;
import io.airbyte.protocol.models.ConfiguredAirbyteStream;
import io.airbyte.protocol.models.SyncMode;
import io.debezium.engine.ChangeEvent;
import java.time.Instant;
import java.util.Collections;
Expand Down Expand Up @@ -120,4 +122,9 @@ private Optional<AirbyteSchemaHistoryStorage> schemaHistoryManager(final CdcSave
return Optional.empty();
}

public static boolean shouldUseCDC(final ConfiguredAirbyteCatalog catalog) {
return catalog.getStreams().stream().map(ConfiguredAirbyteStream::getSyncMode)
.anyMatch(syncMode -> syncMode == SyncMode.INCREMENTAL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import io.airbyte.integrations.debezium.internals.FilteredFileDatabaseHistory;
import io.airbyte.protocol.models.AirbyteMessage;
import io.airbyte.protocol.models.ConfiguredAirbyteCatalog;
import io.airbyte.protocol.models.ConfiguredAirbyteStream;
import io.airbyte.protocol.models.SyncMode;
import io.debezium.engine.ChangeEvent;
import java.time.Instant;
import java.util.Collections;
Expand Down Expand Up @@ -120,4 +122,9 @@ private Optional<AirbyteSchemaHistoryStorage> schemaHistoryManager(final CdcSave
return Optional.empty();
}

public static boolean shouldUseCDC(final ConfiguredAirbyteCatalog catalog) {
return catalog.getStreams().stream().map(ConfiguredAirbyteStream::getSyncMode)
.anyMatch(syncMode -> syncMode == SyncMode.INCREMENTAL);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.airbyte.integrations.source.mssql;

import static io.airbyte.integrations.debezium.AirbyteDebeziumHandler.shouldUseCDC;
import static io.airbyte.integrations.debezium.internals.DebeziumEventUtils.CDC_DELETED_AT;
import static io.airbyte.integrations.debezium.internals.DebeziumEventUtils.CDC_UPDATED_AT;
import static java.util.stream.Collectors.toList;
Expand Down Expand Up @@ -382,13 +383,6 @@ public List<AutoCloseableIterator<AirbyteMessage>> getIncrementalIterators(
}
}

private static boolean shouldUseCDC(final ConfiguredAirbyteCatalog catalog) {
final Optional<SyncMode> any = catalog.getStreams().stream()
.map(ConfiguredAirbyteStream::getSyncMode)
.filter(syncMode -> syncMode == SyncMode.INCREMENTAL).findAny();
return any.isPresent();
}

// Note: in place mutation.
private static AirbyteStream removeIncrementalWithoutPk(final AirbyteStream stream) {
if (stream.getSourceDefinedPrimaryKey().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.airbyte.integrations.source.mysql;

import static io.airbyte.integrations.debezium.AirbyteDebeziumHandler.shouldUseCDC;
import static io.airbyte.integrations.debezium.internals.DebeziumEventUtils.CDC_DELETED_AT;
import static io.airbyte.integrations.debezium.internals.DebeziumEventUtils.CDC_UPDATED_AT;
import static io.airbyte.integrations.source.mysql.helpers.CdcConfigurationHelper.checkBinlog;
Expand Down Expand Up @@ -168,12 +169,6 @@ private static boolean isCdc(final JsonNode config) {
.equals(ReplicationMethod.CDC);
}

private static boolean shouldUseCDC(final ConfiguredAirbyteCatalog catalog) {
final Optional<SyncMode> any = catalog.getStreams().stream().map(ConfiguredAirbyteStream::getSyncMode)
.filter(syncMode -> syncMode == SyncMode.INCREMENTAL).findAny();
return any.isPresent();
}

@Override
public List<AutoCloseableIterator<AirbyteMessage>> getIncrementalIterators(final JdbcDatabase database,
final ConfiguredAirbyteCatalog catalog,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.airbyte.integrations.source.postgres;

import static io.airbyte.integrations.debezium.AirbyteDebeziumHandler.shouldUseCDC;
import static io.airbyte.integrations.debezium.internals.DebeziumEventUtils.CDC_DELETED_AT;
import static io.airbyte.integrations.debezium.internals.DebeziumEventUtils.CDC_UPDATED_AT;
import static java.util.stream.Collectors.toList;
Expand Down Expand Up @@ -249,12 +250,6 @@ public List<AutoCloseableIterator<AirbyteMessage>> getIncrementalIterators(
}
}

private static boolean shouldUseCDC(final ConfiguredAirbyteCatalog catalog) {
final Optional<SyncMode> any = catalog.getStreams().stream().map(ConfiguredAirbyteStream::getSyncMode)
.filter(syncMode -> syncMode == SyncMode.INCREMENTAL).findAny();
return any.isPresent();
}

@VisibleForTesting
static boolean isCdc(final JsonNode config) {
final boolean isCdc = config.hasNonNull("replication_method")
Expand Down

0 comments on commit 7d01727

Please sign in to comment.