def _get_all()

in genai-on-vertex-ai/gemini/evals_playbook/utils/evals_playbook.py [0:0]


    def _get_all(self, table_class, limit_offset=20, as_dict=False):
        client = bigquery.Client(project=cfg.PROJECT_ID)
        table_name = BQ_TABLE_MAP.get(table_class).get("table_name")
        table_id = f"{cfg.PROJECT_ID}.{cfg.BQ_DATASET_ID}.{table_name}"
        table = client.get_table(table_id)
        cols = [schema.name for schema in table.schema]
            
        sql = f"""
            SELECT {", ".join(cols)}
            FROM `{table_id}`
            ORDER BY create_datetime DESC
            LIMIT {limit_offset}
        """
        df = client.query_and_wait(sql).to_dataframe()
        if as_dict:
            return df.to_dict(orient='records')
        else:
            return df