def generate_sql_query(project, dataset_id, table_id, columns=None,
    conditions=None):
    """
    Generates SQL query for querying a BigQuery dataset table
    :param project: project id
    :param dataset_id: bigquery dataset id
    :param table_id: bigquery table id
    :param columns: Array. Columns to select
    :param conditions: Array. conditions the data to retrive needs to satisfy
    :return: STRING of sql
    """
    bq_table = f'{project}.{dataset_id}.{table_id}'
    select = ''
    where_clause = ''
    if not columns:
        select = '*'
    else:
        last_col = len(columns) - 1
        for col in columns:
            if col == columns[last_col]:
                select += f'{col}'
            else:
                select += f'{col}, '
    if conditions:
        last_cond = len(conditions) - 1
        for condition in conditions:
            where_clause = 'WHERE'
            if condition == conditions[last_cond]:
                where_clause += f' {condition}'
            else:
                where_clause += f' {condition} AND'
    query_string = f'SELECT {select} FROM `{bq_table}` {where_clause}'
    return query_string
