def get_total_comparisons_from_join_columns_that_will_be_hash_partitioned(
    df, join_cols: list
):
    """Compute the total number of records that will be generated
    by an inner joi on the join_cols
    For instance, if join_cols = ["first_name", "dmetaphone(surname)"]
    will compute the total number of comparisons generated by the blocking rule:
    ["l.first_name = r.first_name and dmetaphone(l.surname) = dmetaphone(r.surname)"]
    Args:
        df (DataFrame): Input dataframe
        join_cols (list): List of blocking columns e.g. ["first_name", "dmetaphone(surname)"]
    Returns:
        integer: Number of comparisons generated by the blocking rule
    """

    sel_expr = ", ".join(join_cols)
    concat_expr = f"concat({sel_expr})"
    spark = df.sql_ctx.sparkSession

    df.createOrReplaceTempView("df")

    sql = f"""
    with
    block_groups as (
        SELECT {concat_expr}, {sel_expr},
        count(*) * count(*) as num_comparisons
    FROM df
    where {concat_expr} is not null
    GROUP BY {concat_expr}, {sel_expr}
    )
    select sum(num_comparisons) as total_comparisons
    from block_groups
    """

    return spark.sql(sql).collect()[0]["total_comparisons"]