gfw.common.bigquery.TableConfig#

class TableConfig(table_id, schema_file, description=None, partition_type='DAY', partition_field=None, clustering_fields=None, view_suffix='view')[source]#

Abstract base class for BigQuery table configuration.

Methods

delete_query

Returns the query to perform when deleting records from this table.

to_bigquery_params

Returns parameters for BigQuery table creation or write operations.

view_query

Returns the query to perform to create a view for this table.

Attributes

clustering_fields

Optional tuple of fields for clustering.

description

Optional TableDescription instance for the table metadata.

partition_field

Field used for partitioning (optional).

partition_type

Type of partitioning to apply (e.g., DAY, MONTH).

schema

Returns the schema of the table.

view_id

Returns the ID of the view for the table.

view_suffix

Suffix to use when constructing the view ID.

table_id

Fully qualified BigQuery table ID.

schema_file

Path to the file defining the schema.

table_id: str#

Fully qualified BigQuery table ID.

schema_file: str#

Path to the file defining the schema.

description: TableDescription | None = None#

Optional TableDescription instance for the table metadata.

partition_type: str = 'DAY'#

Type of partitioning to apply (e.g., DAY, MONTH).

partition_field: str | None = None#

Field used for partitioning (optional).

clustering_fields: Tuple[str, ...] | None = None#

Optional tuple of fields for clustering.

view_suffix: str | None = 'view'#

Suffix to use when constructing the view ID.

property view_id: str#

Returns the ID of the view for the table.

abstract property schema: list[dict[str, str]]#

Returns the schema of the table.

to_bigquery_params(include_description=True)[source]#

Returns parameters for BigQuery table creation or write operations.

This dictionary is intended to be unpacked as keyword arguments into BigQueryHelper.create_table.

Parameters:

include_description (bool) – Whether to include the formatted description string.

Returns:

A dictionary of parameters suitable for BigQuery operations.

Return type:

dict[str, Any]

view_query()[source]#

Returns the query to perform to create a view for this table.

Return type:

str

delete_query(start_date, end_date=None)[source]#

Returns the query to perform when deleting records from this table.

Return type:

str