From ffe832640561607421ce60b9b7ee526171d730bf Mon Sep 17 00:00:00 2001 From: Connor Sheehan Date: Wed, 30 Oct 2024 18:44:04 -0400 Subject: [PATCH] bigquery: account for `REPEATED` mode in generating schema types --- stats.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stats.py b/stats.py index c0304fa..1e62cca 100755 --- a/stats.py +++ b/stats.py @@ -435,7 +435,14 @@ def get_last_run_timestamp(bq_client: bigquery.Client) -> Optional[datetime]: def load_table_schema(bq_client: bigquery.Client, table_id: str) -> dict[str, str]: """Load a mapping of `field` -> `bigquery type` for the given table.""" table = bq_client.get_table(table_id) - return {field.name: field.field_type for field in table.schema} + return { + field.name: ( + field.field_type + if field.mode != "REPEATED" + else f"ARRAY<{field.field_type}>" + ) + for field in table.schema + } def load_table_schemas(bq_client: bigquery.Client) -> dict[str, dict[str, str]]: