@@ -135,6 +135,56 @@ async def test_run_transfer_postgres_to_clickhouse_with_full_strategy(
135135 assert df .sort ("ID" ).collect () == init_df .sort ("ID" ).collect ()
136136
137137
138+ @pytest .mark .parametrize (
139+ "strategy, transformations" ,
140+ [
141+ (
142+ lf ("incremental_strategy_by_number_column" ),
143+ [],
144+ ),
145+ ],
146+ )
147+ async def test_run_transfer_postgres_to_clickhouse_with_different_strategies (
148+ client : AsyncClient ,
149+ group_owner : MockUser ,
150+ prepare_postgres ,
151+ prepare_clickhouse ,
152+ init_df : DataFrame ,
153+ postgres_to_clickhouse : Transfer ,
154+ update_transfer_strategy ,
155+ strategy ,
156+ transformations ,
157+ ):
158+ """
159+ Run three transfers:
160+
161+ 1. Incremental transfer
162+ 2. Full transfer with HWM reset
163+ 3. Incremental transfer to verify that results match the snapshot.
164+ """
165+ _ , fill_with_data = prepare_postgres
166+ clickhouse , _ = prepare_clickhouse
167+
168+ first_transfer_df , second_transfer_df = split_df (df = init_df , ratio = 0.6 , keep_sorted_by = "number" )
169+ fill_with_data (first_transfer_df )
170+ await run_transfer_and_verify (client , group_owner , postgres_to_clickhouse .id )
171+
172+ fill_with_data (second_transfer_df )
173+ await update_transfer_strategy (postgres_to_clickhouse , "full_strategy" )
174+ await run_transfer_and_verify (client , group_owner , postgres_to_clickhouse .id )
175+
176+ await update_transfer_strategy (postgres_to_clickhouse , "incremental_strategy_by_number_column" )
177+ await run_transfer_and_verify (client , group_owner , postgres_to_clickhouse .id )
178+
179+ reader = DBReader (
180+ connection = clickhouse ,
181+ table = f"{ clickhouse .user } .target_table" ,
182+ )
183+ df = reader .run ()
184+ df , init_df = cast_dataframe_types (df , init_df )
185+ assert df .sort ("ID" ).collect () == init_df .sort ("ID" ).collect ()
186+
187+
138188@pytest .mark .parametrize (
139189 "strategy, transformations" ,
140190 [
@@ -239,11 +289,11 @@ async def test_run_transfer_clickhouse_to_postgres_with_full_strategy(
239289 prepare_clickhouse ,
240290 prepare_postgres ,
241291 init_df : DataFrame ,
292+ clickhouse_to_postgres : Transfer ,
242293 source_type ,
243294 strategy ,
244295 transformations ,
245296 expected_filter ,
246- clickhouse_to_postgres : Transfer ,
247297):
248298 _ , fill_with_data = prepare_clickhouse
249299 fill_with_data (init_df )
@@ -315,9 +365,9 @@ async def test_run_transfer_clickhouse_to_postgres_with_incremental_strategy(
315365 prepare_clickhouse ,
316366 prepare_postgres ,
317367 init_df : DataFrame ,
368+ clickhouse_to_postgres : Transfer ,
318369 strategy ,
319370 transformations ,
320- clickhouse_to_postgres : Transfer ,
321371):
322372 _ , fill_with_data = prepare_clickhouse
323373 postgres , _ = prepare_postgres
0 commit comments