from typing import List


def build_on_conflict_do_nothing_query(
    columns: List[str],
    dest_table: str,
    temp_table: str,
    unique_constraint: str,
    dest_schema: str = "data",
) -> str:
    """
    Construct sql query to insert data originally from `df` into `dest_schema.dest_table` via the
    temporary database table `temp_table`.

    If there are any conflicts on the unique index `pk`, do nothing

    Parameters
    ----------
    columns: List[str]
        A list of column names found in the temporary table that should be inserted into the final table
    dest_table : str
        The destination table
    temp_table : str
        The temporary table name (in public schema)
    unique_constraint : str
        A string referencing the unique key for the destination table
    dest_schema : str
        The name of the postgres schema for the destination

    Returns
    -------
    query: str
        The SQL query for copying data from the tempmorary table to the destination one

    """
    colnames = ", ".join(columns)
    cols = "(" + colnames + ")"
    if not unique_constraint.startswith("("):
        unique_constraint = f"({unique_constraint})"

    return f"""
    INSERT INTO {dest_schema}.{dest_table} {cols}
    SELECT {colnames} from {temp_table}
    ON CONFLICT {unique_constraint} DO NOTHING;
    """