def get_query(dataset, query):
    """Go through the potentially None valued given dataset and query and extract the query."""
    if query:
        return query
    elif dataset.query:
        return dataset.query
    else:
        return f"SELECT * FROM {dataset.table}"