Skip to content

Commit fbed6ac

Browse files
committed
add to test
1 parent 285d505 commit fbed6ac

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/kotlin/io/airbyte/cdk/integrations/destination/jdbc/typing_deduping/JdbcSqlGenerator.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ abstract class JdbcSqlGenerator
4747
constructor(
4848
protected val namingTransformer: NamingConventionTransformer,
4949
private val cascadeDrop: Boolean = false,
50-
private val columns: DestinationColumns = DestinationColumns.V2_WITH_GENERATION,
50+
@VisibleForTesting
51+
internal val columns: DestinationColumns = DestinationColumns.V2_WITH_GENERATION,
5152
) : SqlGenerator {
5253
protected val cdcDeletedAtColumn: ColumnId = buildColumnId("_ab_cdc_deleted_at")
5354

airbyte-cdk/java/airbyte-cdk/db-destinations/src/testFixtures/kotlin/io/airbyte/cdk/integrations/standardtest/destination/typing_deduping/JdbcSqlGeneratorIntegrationTest.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import com.fasterxml.jackson.databind.JsonNode
77
import io.airbyte.cdk.db.jdbc.JdbcDatabase
88
import io.airbyte.cdk.integrations.base.JavaBaseConstants
99
import io.airbyte.cdk.integrations.base.JavaBaseConstants.COLUMN_NAME_AB_EXTRACTED_AT
10+
import io.airbyte.cdk.integrations.base.JavaBaseConstants.COLUMN_NAME_AB_GENERATION_ID
1011
import io.airbyte.cdk.integrations.base.JavaBaseConstants.COLUMN_NAME_AB_ID
1112
import io.airbyte.cdk.integrations.base.JavaBaseConstants.COLUMN_NAME_AB_LOADED_AT
1213
import io.airbyte.cdk.integrations.base.JavaBaseConstants.COLUMN_NAME_AB_META
1314
import io.airbyte.cdk.integrations.base.JavaBaseConstants.COLUMN_NAME_AB_RAW_ID
1415
import io.airbyte.cdk.integrations.base.JavaBaseConstants.COLUMN_NAME_DATA
1516
import io.airbyte.cdk.integrations.base.JavaBaseConstants.COLUMN_NAME_EMITTED_AT
17+
import io.airbyte.cdk.integrations.base.JavaBaseConstants.DestinationColumns
1618
import io.airbyte.cdk.integrations.base.JavaBaseConstants.LEGACY_RAW_TABLE_COLUMNS
1719
import io.airbyte.cdk.integrations.destination.jdbc.typing_deduping.JdbcSqlGenerator
1820
import io.airbyte.integrations.base.destination.typing_deduping.AirbyteProtocolType
@@ -90,16 +92,18 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
9092

9193
@Throws(Exception::class)
9294
override fun createRawTable(streamId: StreamId) {
93-
database.execute(
95+
val columns =
9496
dslContext
9597
.createTable(DSL.name(streamId.rawNamespace, streamId.rawName))
9698
.column(COLUMN_NAME_AB_RAW_ID, SQLDataType.VARCHAR(36).nullable(false))
9799
.column(COLUMN_NAME_AB_EXTRACTED_AT, timestampWithTimeZoneType.nullable(false))
98100
.column(COLUMN_NAME_AB_LOADED_AT, timestampWithTimeZoneType)
99101
.column(COLUMN_NAME_DATA, structType.nullable(false))
100102
.column(COLUMN_NAME_AB_META, structType.nullable(true))
101-
.getSQL(ParamType.INLINED)
102-
)
103+
if (sqlGenerator.columns == DestinationColumns.V2_WITH_GENERATION) {
104+
columns.column(JavaBaseConstants.COLUMN_NAME_AB_GENERATION_ID, SQLDataType.BIGINT)
105+
}
106+
database.execute(columns.getSQL(ParamType.INLINED))
103107
}
104108

105109
@Throws(Exception::class)
@@ -118,7 +122,7 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
118122
public override fun insertRawTableRecords(streamId: StreamId, records: List<JsonNode>) {
119123
insertRecords(
120124
DSL.name(streamId.rawNamespace, streamId.rawName),
121-
JavaBaseConstants.V2_RAW_TABLE_COLUMN_NAMES,
125+
sqlGenerator.columns.rawColumns,
122126
records,
123127
COLUMN_NAME_DATA,
124128
COLUMN_NAME_AB_META
@@ -143,9 +147,12 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
143147
records: List<JsonNode>,
144148
generationId: Long,
145149
) {
146-
// TODO handle generation ID
147150
val columnNames =
148-
if (includeCdcDeletedAt) FINAL_TABLE_COLUMN_NAMES_CDC else FINAL_TABLE_COLUMN_NAMES
151+
(if (includeCdcDeletedAt) FINAL_TABLE_COLUMN_NAMES_CDC else FINAL_TABLE_COLUMN_NAMES)
152+
.toMutableList()
153+
if (sqlGenerator.columns == DestinationColumns.V2_WITH_GENERATION) {
154+
columnNames += COLUMN_NAME_AB_GENERATION_ID
155+
}
149156
insertRecords(
150157
DSL.name(streamId.finalNamespace, streamId.finalName + suffix),
151158
columnNames,

0 commit comments

Comments
 (0)