Skip to content

Commit 367f706

Browse files
authored
Destinations CDK: add test for mixed-case stream name (#44505)
1 parent ff6b1bb commit 367f706

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

airbyte-cdk/java/airbyte-cdk/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ corresponds to that version.
174174

175175
| Version | Date | Pull Request | Subject |
176176
|:-----------|:-----------|:-------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------|
177+
| 0.44.16 | 2024-08-22 | [\#44505](https://github.com/airbytehq/airbyte/pull/44505) | Destinations: add sqlgenerator testing for mixed-case stream name |
178+
| 0.44.15 | ?????????? | [\#?????](https://github.com/airbytehq/airbyte/pull/?????) | ????? |
177179
| 0.44.14 | 2024-08-19 | [\#42503](https://github.com/airbytehq/airbyte/pull/42503) | Destinations (refreshes) - correctly detect existing raw/final table of the correct generation during truncate sync |
178180
| 0.44.13 | 2024-08-14 | [\#42579](https://github.com/airbytehq/airbyte/pull/42579) | S3 destination - OVERWRITE: keep files until successful sync of same generationId |
179181
| 0.44.5 | 2024-08-09 | [\#43374](https://github.com/airbytehq/airbyte/pull/43374) | S3 destination V2 fields, conversion improvements, bugfixes |
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.44.15
1+
version=0.44.16

airbyte-cdk/java/airbyte-cdk/typing-deduping/src/testFixtures/kotlin/io/airbyte/integrations/base/destination/typing_deduping/BaseSqlGeneratorIntegrationTest.kt

+31-14
Original file line numberDiff line numberDiff line change
@@ -521,49 +521,66 @@ abstract class BaseSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
521521
* Verifies two behaviors:
522522
* 1. The isFinalTableEmpty method behaves correctly during a sync
523523
* 2. Column names with mixed case are handled correctly
524-
*
524+
* 3. Stream names with mixed case are handled correctly (under the assumption that destinations
525+
* ```
526+
* that support this will also handle mixed-case namespaces, because this test is annoying
527+
* to set up with a different namespace).
528+
* ```
525529
* The first behavior technically should be its own test, but we might as well just throw it
526530
* into a random testcase to avoid running test setup/teardown again.
527531
*/
528532
@Test
529533
@Throws(java.lang.Exception::class)
530534
fun mixedCaseTest() {
535+
fun toMixedCase(s: String): String =
536+
s.mapIndexed { i, c ->
537+
if (i % 2 == 0) {
538+
c
539+
} else {
540+
c.uppercase()
541+
}
542+
}
543+
.joinToString(separator = "")
544+
val streamId =
545+
sqlGenerator.buildStreamId(
546+
namespace = streamId.originalNamespace,
547+
name = toMixedCase(streamId.originalName),
548+
rawNamespaceOverride = streamId.rawNamespace,
549+
)
550+
val streamConfig = incrementalDedupStream.copy(id = streamId)
551+
531552
// Add case-sensitive columnName to test json path querying
532-
incrementalDedupStream.columns!![generator.buildColumnId("IamACaseSensitiveColumnName")] =
553+
streamConfig.columns[generator.buildColumnId("IamACaseSensitiveColumnName")] =
533554
AirbyteProtocolType.STRING
534555
createRawTable(streamId)
535-
createFinalTable(incrementalDedupStream, "")
556+
createFinalTable(streamConfig, "")
536557
insertRawTableRecords(
537558
streamId,
538559
BaseTypingDedupingTest.readRecords(
539560
"sqlgenerator/mixedcasecolumnname_inputrecords.jsonl"
540561
)
541562
)
542563

543-
var initialState =
544-
getOnly(destinationHandler.gatherInitialState(listOf(incrementalDedupStream)))
564+
var initialState = getOnly(destinationHandler.gatherInitialState(listOf(streamConfig)))
545565
Assertions.assertTrue(
546566
initialState.isFinalTableEmpty,
547567
"Final table should be empty before T+D"
548568
)
549-
550-
executeTypeAndDedupe(
551-
generator,
552-
destinationHandler,
553-
incrementalDedupStream,
554-
Optional.empty(),
555-
""
569+
Assertions.assertTrue(
570+
initialState.isFinalTablePresent,
571+
"Final table should exist after we create it"
556572
)
557573

574+
executeTypeAndDedupe(generator, destinationHandler, streamConfig, Optional.empty(), "")
575+
558576
verifyRecords(
559577
"sqlgenerator/mixedcasecolumnname_expectedrecords_raw.jsonl",
560578
dumpRawTableRecords(streamId),
561579
"sqlgenerator/mixedcasecolumnname_expectedrecords_final.jsonl",
562580
dumpFinalTableRecords(streamId, "")
563581
)
564582

565-
initialState =
566-
getOnly(destinationHandler.gatherInitialState(listOf(incrementalDedupStream)))
583+
initialState = getOnly(destinationHandler.gatherInitialState(listOf(streamConfig)))
567584
assertFalse(initialState.isFinalTableEmpty, "Final table should not be empty after T+D")
568585
}
569586

0 commit comments

Comments
 (0)