File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ def _plan_partitions_for_time_offsets(
8686 for (i , offset ), is_final in partitionmanager .tools .iter_show_end (
8787 enumerate (time_offsets )
8888 ):
89- increase = [x * offset / RATE_UNIT for x in rate_of_change ]
89+ increase = [x * ( offset / RATE_UNIT ) for x in rate_of_change ]
9090 predicted_positions = [
9191 int (p + i ) for p , i in zip (ordered_current_pos , increase )
9292 ]
Original file line number Diff line number Diff line change 99 _suffix ,
1010 _trigger_column_copies ,
1111 _override_config_to_map_data ,
12+ _plan_partitions_for_time_offsets ,
1213 calculate_sql_alters_from_state_info ,
1314 write_state_info ,
1415)
1516from .cli import Config
16- from .types import DatabaseCommand , Table , SqlInput
17+ from .types import (
18+ DatabaseCommand ,
19+ Table ,
20+ SqlInput ,
21+ MaxValuePartition ,
22+ ChangePlannedPartition ,
23+ NewPlannedPartition ,
24+ )
1725
1826
1927class MockDatabase (DatabaseCommand ):
@@ -251,3 +259,14 @@ def test_generate_sql_copy_commands(self):
251259 "\t \t WHERE `id` = NEW.`id`;" ,
252260 ],
253261 )
262+
263+ def test_plan_partitions_for_time_offsets (self ):
264+ parts = _plan_partitions_for_time_offsets (
265+ datetime (2021 , 3 , 3 ),
266+ [timedelta (days = 60 ), timedelta (days = 360 )],
267+ [11943234 ],
268+ [16753227640 ],
269+ MaxValuePartition ("p_assumed" , count = 1 ),
270+ )
271+ self .assertIsInstance (parts [0 ], ChangePlannedPartition )
272+ self .assertIsInstance (parts [1 ], NewPlannedPartition )
You can’t perform that action at this time.
0 commit comments