File tree 2 files changed +21
-2
lines changed
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(
86
86
for (i , offset ), is_final in partitionmanager .tools .iter_show_end (
87
87
enumerate (time_offsets )
88
88
):
89
- increase = [x * offset / RATE_UNIT for x in rate_of_change ]
89
+ increase = [x * ( offset / RATE_UNIT ) for x in rate_of_change ]
90
90
predicted_positions = [
91
91
int (p + i ) for p , i in zip (ordered_current_pos , increase )
92
92
]
Original file line number Diff line number Diff line change 9
9
_suffix ,
10
10
_trigger_column_copies ,
11
11
_override_config_to_map_data ,
12
+ _plan_partitions_for_time_offsets ,
12
13
calculate_sql_alters_from_state_info ,
13
14
write_state_info ,
14
15
)
15
16
from .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
+ )
17
25
18
26
19
27
class MockDatabase (DatabaseCommand ):
@@ -251,3 +259,14 @@ def test_generate_sql_copy_commands(self):
251
259
"\t \t WHERE `id` = NEW.`id`;" ,
252
260
],
253
261
)
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