Skip to content

Commit

Permalink
Don't divide by zero (#53)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jcjones authored May 28, 2022
1 parent c449afe commit 8760d24
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions partitionmanager/table_append_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ def _get_weighted_position_increase_per_day_for_partitions(partitions):
more, and returns a final list of weighted partition-position-increase-per-
day, with one entry per column.
"""
log = logging.getLogger("get_weighted_position_increase_per_day_for_partitions")

if not partitions:
raise ValueError("Partition list must not be empty")

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

if not pos_rates or not weights:
log.error(
"No rates of change were valid for the partition list: %s", partitions
)
raise ValueError("No valid rates of change")

# Initialize a list with a zero for each position
weighted_sums = [0] * partitions[0].num_columns

Expand Down

0 comments on commit 8760d24

Please sign in to comment.