Skip to content

Commit

Permalink
Destinations CDK: add test for mixed-case stream name (#44505)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgao authored Aug 22, 2024
1 parent ff6b1bb commit 367f706
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
2 changes: 2 additions & 0 deletions airbyte-cdk/java/airbyte-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ corresponds to that version.

| Version | Date | Pull Request | Subject |
|:-----------|:-----------|:-------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 0.44.16 | 2024-08-22 | [\#44505](https://github.com/airbytehq/airbyte/pull/44505) | Destinations: add sqlgenerator testing for mixed-case stream name |
| 0.44.15 | ?????????? | [\#?????](https://github.com/airbytehq/airbyte/pull/?????) | ????? |
| 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 |
| 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 |
| 0.44.5 | 2024-08-09 | [\#43374](https://github.com/airbytehq/airbyte/pull/43374) | S3 destination V2 fields, conversion improvements, bugfixes |
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.44.15
version=0.44.16
Original file line number Diff line number Diff line change
Expand Up @@ -521,49 +521,66 @@ abstract class BaseSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
* Verifies two behaviors:
* 1. The isFinalTableEmpty method behaves correctly during a sync
* 2. Column names with mixed case are handled correctly
*
* 3. Stream names with mixed case are handled correctly (under the assumption that destinations
* ```
* that support this will also handle mixed-case namespaces, because this test is annoying
* to set up with a different namespace).
* ```
* The first behavior technically should be its own test, but we might as well just throw it
* into a random testcase to avoid running test setup/teardown again.
*/
@Test
@Throws(java.lang.Exception::class)
fun mixedCaseTest() {
fun toMixedCase(s: String): String =
s.mapIndexed { i, c ->
if (i % 2 == 0) {
c
} else {
c.uppercase()
}
}
.joinToString(separator = "")
val streamId =
sqlGenerator.buildStreamId(
namespace = streamId.originalNamespace,
name = toMixedCase(streamId.originalName),
rawNamespaceOverride = streamId.rawNamespace,
)
val streamConfig = incrementalDedupStream.copy(id = streamId)

// Add case-sensitive columnName to test json path querying
incrementalDedupStream.columns!![generator.buildColumnId("IamACaseSensitiveColumnName")] =
streamConfig.columns[generator.buildColumnId("IamACaseSensitiveColumnName")] =
AirbyteProtocolType.STRING
createRawTable(streamId)
createFinalTable(incrementalDedupStream, "")
createFinalTable(streamConfig, "")
insertRawTableRecords(
streamId,
BaseTypingDedupingTest.readRecords(
"sqlgenerator/mixedcasecolumnname_inputrecords.jsonl"
)
)

var initialState =
getOnly(destinationHandler.gatherInitialState(listOf(incrementalDedupStream)))
var initialState = getOnly(destinationHandler.gatherInitialState(listOf(streamConfig)))
Assertions.assertTrue(
initialState.isFinalTableEmpty,
"Final table should be empty before T+D"
)

executeTypeAndDedupe(
generator,
destinationHandler,
incrementalDedupStream,
Optional.empty(),
""
Assertions.assertTrue(
initialState.isFinalTablePresent,
"Final table should exist after we create it"
)

executeTypeAndDedupe(generator, destinationHandler, streamConfig, Optional.empty(), "")

verifyRecords(
"sqlgenerator/mixedcasecolumnname_expectedrecords_raw.jsonl",
dumpRawTableRecords(streamId),
"sqlgenerator/mixedcasecolumnname_expectedrecords_final.jsonl",
dumpFinalTableRecords(streamId, "")
)

initialState =
getOnly(destinationHandler.gatherInitialState(listOf(incrementalDedupStream)))
initialState = getOnly(destinationHandler.gatherInitialState(listOf(streamConfig)))
assertFalse(initialState.isFinalTableEmpty, "Final table should not be empty after T+D")
}

Expand Down

0 comments on commit 367f706

Please sign in to comment.