Skip to content

Commit 981eb38

Browse files
committed
Don't divide by zero
Fix #39 This mostly just improves the logging. This can still happen if the partitions have out-of-order numbers, which is going to be handled more in #51
1 parent 2e29cd1 commit 981eb38

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

partitionmanager/table_append_partition.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ def _get_weighted_position_increase_per_day_for_partitions(partitions):
270270
more, and returns a final list of weighted partition-position-increase-per-
271271
day, with one entry per column.
272272
"""
273+
log = logging.getLogger("get_weighted_position_increase_per_day_for_partitions")
274+
273275
if not partitions:
274276
raise ValueError("Partition list must not be empty")
275277

@@ -279,6 +281,12 @@ def _get_weighted_position_increase_per_day_for_partitions(partitions):
279281
]
280282
weights = _generate_weights(len(pos_rates))
281283

284+
if not pos_rates or not weights:
285+
log.error(
286+
"No rates of change were valid for the partition list: %s", partitions
287+
)
288+
raise ValueError("No valid rates of change")
289+
282290
# Initialize a list with a zero for each position
283291
weighted_sums = [0] * partitions[0].num_columns
284292

0 commit comments

Comments
 (0)