def METHOD_NAME(output_dir, full_table_id, basename, sql, skip_existing=False):
    """Write out a query to a location based on the table ID.
    :param output_dir:    Base target directory (probably sql/moz-fx-data-shared-prod/)
    :param full_table_id: Table ID in project.dataset.table form
    :param basename:      The name to give the written file (like query.sql)
    :param sql:           The query content to write out
    :param skip_existing: Whether to skip an existing file rather than overwriting it
    """
    d = get_table_dir(output_dir, full_table_id)
    d.mkdir(parents=True, exist_ok=True)
    target = d / basename
    if skip_existing and target.exists():
        logging.info(f"Not writing {target} because it already exists")
        return
    logging.info(f"Writing {target}")
    with target.open("w") as f:
        f.write(sql)
        f.write("\n")