from typing import List
import re


def _is_unified_dataset(
    dataset_name: str,
    *,
    check_regex: bool = True,
    regex=".*unified_dataset$",
    all_unified_datasets: List[str],
) -> bool:
    """Check if a dataset is or used to be unified dataset.

    Args:
        dataset_name: Name of the target dataset.
        check_regex: A Boolean to determine whether to check for regex matching if a dataset is
            not part of the pipeline (if its project has been deleted.) Default to True.
        regex: A string of regex to check. Default to '.*unified_dataset$' which is Tamr's current
            default unified dataset naming.
        all_unified_datasets: List of unified dataset names.

    Returns:
        A Boolean, if True, the target `dataset` is or used to be unified dataset.

    """
    # check project pipeline (only works if project has not been deleted)
    if dataset_name in all_unified_datasets:
        return True
    # check regex
    if check_regex:
        return re.search(regex, dataset_name) is not None
    return False