gfw.common.bigquery.Schema#

class Schema(fields)[source]#

A BigQuery schema with conversion utilities.

Wraps a list of SchemaField objects and provides methods to convert to other formats.

Parameters:

fields (list[bigquery.SchemaField]) – List of BigQuery schema fields.

Methods

as_dicts

Return the schema as a list of BigQuery field descriptor dicts.

as_pyarrow

Convert to a pyarrow.Schema.

from_dicts

Construct a Schema from a list of BigQuery field descriptor dicts.

from_json

Load a BigQuery JSON schema file and return a Schema.

Attributes

fields

The raw BigQuery SchemaField list.

classmethod from_dicts(dicts)[source]#

Construct a Schema from a list of BigQuery field descriptor dicts.

Parameters:

dicts (list[dict[str, Any]]) – List of BigQuery field descriptors, each with at minimum name and type keys. Supports optional mode and fields for nested RECORD types.

Returns:

A Schema wrapping the parsed fields.

Return type:

Schema

classmethod from_json(path)[source]#

Load a BigQuery JSON schema file and return a Schema.

Parameters:

path (str | Path) – Path to a JSON file containing a list of BigQuery field descriptors.

Returns:

A Schema wrapping the parsed fields.

Return type:

Schema

property fields: list[SchemaField]#

The raw BigQuery SchemaField list.

as_dicts()[source]#

Return the schema as a list of BigQuery field descriptor dicts.

Useful when passing a schema to interfaces that expect the JSON dict format (e.g. WriteToBigQueryWrapper).

Return type:

list[Dict[str, Any]]

as_pyarrow()[source]#

Convert to a pyarrow.Schema.

Return type:

Schema