Skip to content

Commit

Permalink
bigquery: correct type hint to bigquery.SchemaField
Browse files Browse the repository at this point in the history
  • Loading branch information
cgsheeh committed Oct 30, 2024
1 parent d0eca3e commit 02a9f89
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,15 @@ def get_last_run_timestamp(bq_client: bigquery.Client) -> Optional[datetime]:

def load_table_schema(
bq_client: bigquery.Client, table_id: str
) -> dict[str, bigquery.TableFieldSchema]:
) -> dict[str, bigquery.SchemaField]:
"""Load a mapping of `field` -> `bigquery type` for the given table."""
table = bq_client.get_table(table_id)
return {field.name: field for field in table.schema}


def load_table_schemas(
bq_client: bigquery.Client,
) -> dict[str, dict[str, bigquery.TableFieldSchema]]:
) -> dict[str, dict[str, bigquery.SchemaField]]:
"""Return a mapping of each table ID to the table field->type schema."""
return {
BQ_REVISIONS_TABLE_ID: load_table_schema(bq_client, BQ_REVISIONS_TABLE_ID),
Expand Down Expand Up @@ -484,7 +484,7 @@ def merge_into_bigquery(
bq_client: bigquery.Client,
table_id: str,
id_column: str,
table_schema_mapping: dict[str, bigquery.TableFieldSchema],
table_schema_mapping: dict[str, bigquery.SchemaField],
row: dict[str, Any],
):
"""Use a `MERGE` statement to upsert rows into BigQuery.
Expand Down Expand Up @@ -530,7 +530,7 @@ def merge_into_bigquery(

def submit_to_bigquery(
bq_client: bigquery.Client,
table_schema_mappings: dict[str, dict[str, bigquery.TableFieldSchema]],
table_schema_mappings: dict[str, dict[str, bigquery.SchemaField]],
table_id: str,
id_column: str,
rows: list[dict],
Expand Down

0 comments on commit 02a9f89

Please sign in to comment.