destinations.impl.bigquery.bigquery_adapter
bigquery_adapter
def bigquery_adapter(
data: Any,
partition: TColumnNames = None,
cluster: TColumnNames = None,
round_half_away_from_zero: TColumnNames = None,
round_half_even: TColumnNames = None,
table_description: Optional[str] = None,
table_expiration_datetime: Optional[str] = None) -> DltResource
Prepares data for loading into BigQuery.
This function takes data, which can be raw or already wrapped in a DltResource object, and prepares it for BigQuery by optionally specifying partitioning, clustering, table description and table expiration settings.
Arguments:
data
Any - The data to be transformed. This can be raw data or an instance of DltResource. If raw data is provided, the function will wrap it into aDltResource
object.partition
TColumnNames, optional - The name of the column to partition the BigQuery table by. This should be a string representing a single column name.cluster
TColumnNames, optional - A column name or list of column names to cluster the BigQuery table by.round_half_away_from_zero
TColumnNames, optional - Determines how values in the column are rounded when written to the table. This mode rounds halfway cases away from zero. The columns specified must be mutually exclusive fromround_half_even
. See https://cloud.google.com/bigquery/docs/schemas#rounding_mode for more information.round_half_even
TColumnNames, optional - Determines how values in the column are rounded when written to the table. This mode rounds halfway cases towards the nearest even digit. The columns specified must be mutually exclusive fromround_half_away_from_zero
. See https://cloud.google.com/bigquery/docs/schemas#rounding_mode for more information.table_description
str, optional - A description for the BigQuery table.table_expiration_datetime
str, optional - String representing the datetime when the BigQuery table expires. This is always interpreted as UTC, BigQuery's default.
Returns:
A DltResource
object that is ready to be loaded into BigQuery.
Raises:
ValueError
- If any hint is invalid or none are specified.
Examples:
data = [{"name": "Marcel", "description": "Raccoon Engineer", "date_hired": 1700784000}]
bigquery_adapter(data, partition="date_hired", table_expiration_datetime="2024-01-30", table_description="Employee Data")
[DltResource with hints applied]