Skip to content

Commit 6303575

Browse files
committed
support unsafe_cast via test mutation
1 parent b846503 commit 6303575

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
import static java.util.Collections.emptyList;
88
import static java.util.Collections.singletonList;
9+
import static java.util.stream.Collectors.toList;
910
import static org.junit.jupiter.api.Assertions.assertAll;
1011
import static org.junit.jupiter.api.Assertions.assertEquals;
1112
import static org.junit.jupiter.api.Assertions.assertFalse;
1213
import static org.junit.jupiter.api.Assertions.assertNull;
1314
import static org.junit.jupiter.api.Assertions.assertThrows;
1415
import static org.junit.jupiter.api.Assertions.assertTrue;
1516
import static org.junit.jupiter.api.Assertions.fail;
17+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
1618

1719
import com.fasterxml.jackson.databind.JsonNode;
1820
import com.google.common.collect.Streams;
@@ -148,6 +150,8 @@ protected StreamId buildStreamId(final String namespace, final String finalTable
148150
protected abstract void insertFinalTableRecords(boolean includeCdcDeletedAt, StreamId streamId, String suffix, List<JsonNode> records)
149151
throws Exception;
150152

153+
protected abstract boolean supportsSafeCast();
154+
151155
/**
152156
* The two dump methods are defined identically as in {@link BaseTypingDedupingTest}, but with
153157
* slightly different method signature. This test expects subclasses to respect the raw/finalTableId
@@ -412,7 +416,10 @@ public void allTypes() throws Exception {
412416
createFinalTable(incrementalDedupStream, "");
413417
insertRawTableRecords(
414418
streamId,
415-
BaseTypingDedupingTest.readRecords("sqlgenerator/alltypes_inputrecords.jsonl"));
419+
BaseTypingDedupingTest.readRecords("sqlgenerator/alltypes_inputrecords.jsonl")
420+
.stream()
421+
.filter(record -> record.get("test_config").get("requires_safe_cast_support").asBoolean())
422+
.collect(toList()));
416423

417424
assertTrue(destinationHandler.isFinalTableEmpty(streamId), "Final table should be empty before T+D");
418425

airbyte-cdk/java/airbyte-cdk/typing-deduping/src/testFixtures/resources/sqlgenerator/alltypes_inputrecords.jsonl

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
{"_airbyte_raw_id": "53ce75a5-5bcc-47a3-b45c-96c2015cfe35", "_airbyte_extracted_at": "2023-01-01T00:00:00Z", "_airbyte_data": {"id1": 2, "id2": 100, "updated_at": "2023-01-01T01:00:00Z", "array": null, "struct": null, "string": null, "number": null, "integer": null, "boolean": null, "timestamp_with_timezone": null, "timestamp_without_timezone": null, "time_with_timezone": null, "time_without_timezone": null, "date": null, "unknown": null}}
33
{"_airbyte_raw_id": "7e1fac0c-017e-4ad6-bc78-334a34d64fbe", "_airbyte_extracted_at": "2023-01-01T00:00:00Z", "_airbyte_data": {"id1": 3, "id2": 100, "updated_at": "2023-01-01T01:00:00Z"}}
44
// Note that array and struct have invalid values ({} and [] respectively).
5-
{"_airbyte_raw_id": "84242b60-3a34-4531-ad75-a26702960a9a", "_airbyte_extracted_at": "2023-01-01T00:00:00Z", "_airbyte_data": {"id1": 4, "id2": 100, "updated_at": "2023-01-01T01:00:00Z", "array": {}, "struct": [], "string": null, "number": "foo", "integer": "bar", "boolean": "fizz", "timestamp_with_timezone": {}, "timestamp_without_timezone": {}, "time_with_timezone": {}, "time_without_timezone": {}, "date": "airbyte", "unknown": null}}
5+
{"_airbyte_raw_id": "84242b60-3a34-4531-ad75-a26702960a9a", "_airbyte_extracted_at": "2023-01-01T00:00:00Z", "_airbyte_data": {"id1": 4, "id2": 100, "updated_at": "2023-01-01T01:00:00Z", "array": {}, "struct": [], "string": null, "number": "foo", "integer": "bar", "boolean": "fizz", "timestamp_with_timezone": {}, "timestamp_without_timezone": {}, "time_with_timezone": {}, "time_without_timezone": {}, "date": "airbyte", "unknown": null}, "test_config": {"requires_safe_cast_support": true}}
66
{"_airbyte_raw_id": "a4a783b5-7729-4d0b-b659-48ceb08713f1", "_airbyte_extracted_at": "2023-01-01T00:00:00Z", "_airbyte_data": {"id1": 5, "id2": 100, "updated_at": "2023-01-01T01:00:00Z", "number": 67.174118, "struct": {"nested_number": 67.174118}, "array": [67.174118], "unknown": 67.174118}}
7-
{"_airbyte_raw_id": "7e1fac0c-017e-4ad6-bc78-334a34d64fce", "_airbyte_extracted_at": "2023-01-01T00:00:00Z", "_airbyte_data": {"id1": 6, "id2": 100, "updated_at": "2023-01-01T01:00:00Z", "IamACaseSensitiveColumnName": "Case senstive value"}}
7+
{"_airbyte_raw_id": "7e1fac0c-017e-4ad6-bc78-334a34d64fce", "_airbyte_extracted_at": "2023-01-01T00:00:00Z", "_airbyte_data": {"id1": 6, "id2": 100, "updated_at": "2023-01-01T01:00:00Z", "IamACaseSensitiveColumnName": "Case senstive value"}}

0 commit comments

Comments
 (0)