Skip to content

Commit 2e8687f

Browse files
committed
Fix the failing unit test
1 parent e2cf3fd commit 2e8687f

File tree

2 files changed

+62
-52
lines changed

2 files changed

+62
-52
lines changed

airbyte-integrations/connectors/destination-redshift/src/test/java/io/airbyte/integrations/destination/redshift/typing_deduping/RedshiftSqlGeneratorTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ public void testTypingAndDeduping() throws IOException {
104104
.map(String::trim)
105105
.filter(line -> !line.isEmpty())
106106
.toList();
107-
System.out.println(generatedSql);
108-
assertEquals(expectedSqlLines, generatedSqlLines);
107+
assertEquals(expectedSqlLines.size(), generatedSqlLines.size());
108+
for (int i = 0; i < expectedSqlLines.size(); i++) {
109+
assertEquals(expectedSqlLines.get(i), generatedSqlLines.get(i));
110+
}
109111
}
110112

111113
@Test

airbyte-integrations/connectors/destination-redshift/src/test/resources/typing_deduping_with_cdc.sql

+58-50
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ with
4545
"_airbyte_raw_id",
4646
"_airbyte_extracted_at",
4747
OBJECT(
48-
'errors',
48+
'changes',
4949
ARRAY_CONCAT(
5050
ARRAY_CONCAT(
5151
ARRAY_CONCAT(
@@ -61,84 +61,92 @@ with
6161
ARRAY_CONCAT(
6262
ARRAY_CONCAT(
6363
ARRAY_CONCAT(
64+
ARRAY_CONCAT(
65+
CASE WHEN (
66+
"_airbyte_data"."id1" is not null
67+
and "id1" is null
68+
) THEN ARRAY(JSON_PARSE('{"field": "id1", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END ,
69+
CASE WHEN (
70+
"_airbyte_data"."id2" is not null
71+
and "id2" is null
72+
) THEN ARRAY(JSON_PARSE('{"field": "id2", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
73+
),
6474
CASE WHEN (
65-
"_airbyte_data"."id1" is not null
66-
and "id1" is null
67-
) THEN ARRAY('Problem with `id1`') ELSE ARRAY() END ,
68-
CASE WHEN (
69-
"_airbyte_data"."id2" is not null
70-
and "id2" is null
71-
) THEN ARRAY('Problem with `id2`') ELSE ARRAY() END
75+
"_airbyte_data"."updated_at" is not null
76+
and "updated_at" is null
77+
) THEN ARRAY(JSON_PARSE('{"field": "updated_at", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
7278
),
7379
CASE WHEN (
74-
"_airbyte_data"."updated_at" is not null
75-
and "updated_at" is null
76-
) THEN ARRAY('Problem with `updated_at`') ELSE ARRAY() END
80+
"_airbyte_data"."struct" is not null
81+
and "struct" is null
82+
) THEN ARRAY(JSON_PARSE('{"field": "struct", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
7783
),
7884
CASE WHEN (
79-
"_airbyte_data"."struct" is not null
80-
and "struct" is null
81-
) THEN ARRAY('Problem with `struct`') ELSE ARRAY() END
85+
"_airbyte_data"."array" is not null
86+
and "array" is null
87+
) THEN ARRAY(JSON_PARSE('{"field": "array", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
8288
),
8389
CASE WHEN (
84-
"_airbyte_data"."array" is not null
85-
and "array" is null
86-
) THEN ARRAY('Problem with `array`') ELSE ARRAY() END
90+
"_airbyte_data"."string" is not null
91+
and "string" is null
92+
) THEN ARRAY(JSON_PARSE('{"field": "string", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
8793
),
8894
CASE WHEN (
89-
"_airbyte_data"."string" is not null
90-
and "string" is null
91-
) THEN ARRAY('Problem with `string`') ELSE ARRAY() END
95+
"_airbyte_data"."number" is not null
96+
and "number" is null
97+
) THEN ARRAY(JSON_PARSE('{"field": "number", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
9298
),
9399
CASE WHEN (
94-
"_airbyte_data"."number" is not null
95-
and "number" is null
96-
) THEN ARRAY('Problem with `number`') ELSE ARRAY() END
100+
"_airbyte_data"."integer" is not null
101+
and "integer" is null
102+
) THEN ARRAY(JSON_PARSE('{"field": "integer", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
97103
),
98104
CASE WHEN (
99-
"_airbyte_data"."integer" is not null
100-
and "integer" is null
101-
) THEN ARRAY('Problem with `integer`') ELSE ARRAY() END
105+
"_airbyte_data"."boolean" is not null
106+
and "boolean" is null
107+
) THEN ARRAY(JSON_PARSE('{"field": "boolean", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
102108
),
103109
CASE WHEN (
104-
"_airbyte_data"."boolean" is not null
105-
and "boolean" is null
106-
) THEN ARRAY('Problem with `boolean`') ELSE ARRAY() END
110+
"_airbyte_data"."timestamp_with_timezone" is not null
111+
and "timestamp_with_timezone" is null
112+
) THEN ARRAY(JSON_PARSE('{"field": "timestamp_with_timezone", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
107113
),
108114
CASE WHEN (
109-
"_airbyte_data"."timestamp_with_timezone" is not null
110-
and "timestamp_with_timezone" is null
111-
) THEN ARRAY('Problem with `timestamp_with_timezone`') ELSE ARRAY() END
115+
"_airbyte_data"."timestamp_without_timezone" is not null
116+
and "timestamp_without_timezone" is null
117+
) THEN ARRAY(JSON_PARSE('{"field": "timestamp_without_timezone", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
112118
),
113119
CASE WHEN (
114-
"_airbyte_data"."timestamp_without_timezone" is not null
115-
and "timestamp_without_timezone" is null
116-
) THEN ARRAY('Problem with `timestamp_without_timezone`') ELSE ARRAY() END
120+
"_airbyte_data"."time_with_timezone" is not null
121+
and "time_with_timezone" is null
122+
) THEN ARRAY(JSON_PARSE('{"field": "time_with_timezone", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
117123
),
118124
CASE WHEN (
119-
"_airbyte_data"."time_with_timezone" is not null
120-
and "time_with_timezone" is null
121-
) THEN ARRAY('Problem with `time_with_timezone`') ELSE ARRAY() END
125+
"_airbyte_data"."time_without_timezone" is not null
126+
and "time_without_timezone" is null
127+
) THEN ARRAY(JSON_PARSE('{"field": "time_without_timezone", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
122128
),
123129
CASE WHEN (
124-
"_airbyte_data"."time_without_timezone" is not null
125-
and "time_without_timezone" is null
126-
) THEN ARRAY('Problem with `time_without_timezone`') ELSE ARRAY() END
130+
"_airbyte_data"."date" is not null
131+
and "date" is null
132+
) THEN ARRAY(JSON_PARSE('{"field": "date", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
127133
),
128134
CASE WHEN (
129-
"_airbyte_data"."date" is not null
130-
and "date" is null
131-
) THEN ARRAY('Problem with `date`') ELSE ARRAY() END
135+
"_airbyte_data"."unknown" is not null
136+
and "unknown" is null
137+
) THEN ARRAY(JSON_PARSE('{"field": "unknown", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
132138
),
133139
CASE WHEN (
134-
"_airbyte_data"."unknown" is not null
135-
and "unknown" is null
136-
) THEN ARRAY('Problem with `unknown`') ELSE ARRAY() END
140+
"_airbyte_data"."_ab_cdc_deleted_at" is not null
141+
and "_ab_cdc_deleted_at" is null
142+
) THEN ARRAY(JSON_PARSE('{"field": "_ab_cdc_deleted_at", "change": "NULLED", "reason": "DESTINATION_TYPECAST_ERROR"}')) ELSE ARRAY() END
137143
),
138144
CASE WHEN (
139-
"_airbyte_data"."_ab_cdc_deleted_at" is not null
140-
and "_ab_cdc_deleted_at" is null
141-
) THEN ARRAY('Problem with `_ab_cdc_deleted_at`') ELSE ARRAY() END
145+
"_airbyte_meta" is not null
146+
and IS_OBJECT("_airbyte_meta")
147+
and "_airbyte_meta"."changes" is not null
148+
and IS_ARRAY("_airbyte_meta"."changes")
149+
) THEN "_airbyte_meta"."changes" ELSE ARRAY() END
142150
)
143151
) as "_airbyte_meta"
144152
from "test_schema"."users_raw"

0 commit comments

Comments
 (0)