Skip to content

Commit 0154bbc

Browse files
committed
Add additional check to skip v1v2 migration
1 parent f31f42c commit 0154bbc

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/base/JavaBaseConstants.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package io.airbyte.cdk.integrations.base;
66

77
import java.util.List;
8+
import java.util.Set;
89

910
public final class JavaBaseConstants {
1011

@@ -34,7 +35,7 @@ private JavaBaseConstants() {}
3435

3536
// Meta was introduced later, so to avoid triggering raw table soft-reset in v1->v2
3637
// use this column list.
37-
public static final List<String> V2_RAW_TABLE_COLUMN_NAMES_WITHOUT_META = List.of(
38+
public static final Set<String> V2_RAW_TABLE_COLUMN_NAMES_WITHOUT_META = Set.of(
3839
COLUMN_NAME_AB_RAW_ID,
3940
COLUMN_NAME_AB_EXTRACTED_AT,
4041
COLUMN_NAME_AB_LOADED_AT,

airbyte-cdk/java/airbyte-cdk/typing-deduping/src/main/java/io/airbyte/integrations/base/destination/typing_deduping/BaseDestinationV1V2Migrator.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package io.airbyte.integrations.base.destination.typing_deduping;
66

77
import static io.airbyte.cdk.integrations.base.JavaBaseConstants.LEGACY_RAW_TABLE_COLUMNS;
8+
import static io.airbyte.cdk.integrations.base.JavaBaseConstants.V2_RAW_TABLE_COLUMN_NAMES;
89
import static io.airbyte.cdk.integrations.base.JavaBaseConstants.V2_RAW_TABLE_COLUMN_NAMES_WITHOUT_META;
910

1011
import io.airbyte.protocol.models.v0.DestinationSyncMode;
@@ -89,7 +90,10 @@ private boolean doesV1RawTableMatchExpectedSchema(final DialectTableDefinition e
8990
* @param existingV2AirbyteRawTable the v2 raw table
9091
*/
9192
private void validateAirbyteInternalNamespaceRawTableMatchExpectedV2Schema(final DialectTableDefinition existingV2AirbyteRawTable) {
92-
if (!schemaMatchesExpectation(existingV2AirbyteRawTable, V2_RAW_TABLE_COLUMN_NAMES_WITHOUT_META)) {
93+
// Account for the fact that the meta column was added later, so skip the rebuilding of the raw
94+
// table.
95+
if (!(schemaMatchesExpectation(existingV2AirbyteRawTable, V2_RAW_TABLE_COLUMN_NAMES_WITHOUT_META) ||
96+
schemaMatchesExpectation(existingV2AirbyteRawTable, V2_RAW_TABLE_COLUMN_NAMES))) {
9397
throw new UnexpectedSchemaException("Destination V2 Raw Table does not match expected Schema");
9498
}
9599
}

airbyte-cdk/java/airbyte-cdk/typing-deduping/src/test/java/io/airbyte/integrations/base/destination/typing_deduping/DestinationV1V2MigratorTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package io.airbyte.integrations.base.destination.typing_deduping;
66

77
import static io.airbyte.cdk.integrations.base.JavaBaseConstants.LEGACY_RAW_TABLE_COLUMNS;
8+
import static io.airbyte.cdk.integrations.base.JavaBaseConstants.V2_RAW_TABLE_COLUMN_NAMES;
89
import static io.airbyte.cdk.integrations.base.JavaBaseConstants.V2_RAW_TABLE_COLUMN_NAMES_WITHOUT_META;
910
import static org.mockito.ArgumentMatchers.any;
1011

@@ -97,6 +98,7 @@ public static BaseDestinationV1V2Migrator makeMockMigrator(final boolean v2Names
9798
Mockito.when(migrator.doesAirbyteInternalNamespaceExist(any())).thenReturn(v2NamespaceExists);
9899
final var existingTable = v2TableExists ? Optional.of("v2_raw") : Optional.empty();
99100
Mockito.when(migrator.getTableIfExists("raw", "raw_table")).thenReturn(existingTable);
101+
Mockito.when(migrator.schemaMatchesExpectation("v2_raw", V2_RAW_TABLE_COLUMN_NAMES)).thenReturn(false);
100102
Mockito.when(migrator.schemaMatchesExpectation("v2_raw", V2_RAW_TABLE_COLUMN_NAMES_WITHOUT_META)).thenReturn(v2RawSchemaMatches);
101103

102104
Mockito.when(migrator.convertToV1RawName(any())).thenReturn(new NamespacedTableName("v1_raw_namespace", "v1_raw_table"));

0 commit comments

Comments
 (0)