def _calc_splits(df, num_buckets=100):
    """Calculate the right edge of num_session buckets

    Utilizes approxQuantile to bucketize the source. Due to the available
    implementation this has to be done per-wiki, so is perhaps slower than
    necessary. For current dataset sizes that isn't an issue.

    We need to bucketize the number of sessions so we can split the
    per-wiki input into strata and sample from each bucket. This helps
    ensure we keep a consistent distribution of popular and unpopular
    queries from the input to the output.

    Parameters
    ----------
    df : pyspark.sql.DataFrame
        Input dataframe to have bucketing fractions calculated for.
    num_buckets : int
        Number of buckets to create per-wiki

    Returns
    -------
    list of ints
        List of right-edges of buckets that will have an approximately equal number
        of queries per bucket.
    """

    percentiles = [x/float(num_buckets) for x in range(1, num_buckets)]
    # With 100 buckets, there will be buckets at .01, .02, etc. This specifies
    # percentils .01 must be the value between .009 and .011
    relative_error = 1. / (num_buckets * 10)
    splits = df.approxQuantile('num_sessions', percentiles, relative_error)

    # range(1, num_buckets) returned num_buckets-1 values. This final inf captures
    # everything from the last bucket to the end.
    return splits + [float('inf')]