Skip to content

Allow Configuring Dataset Location in BigQuery Cache #688

Description

I’m using BigQuery as a cache to load data into BigQuery directly (as recommended in the documentation). This avoids the unnecessary overhead of creating a local cache.

However, the current implementation hardcodes the dataset location to "US" and doesn’t provide a way to change it. This becomes a problem when your existing datasets are in other locations, since BigQuery doesn’t support querying across regions.

Here's the relevant code:

def bigquery_cache_to_destination_configuration(
    cache: BigQueryCache,
) -> DestinationBigquery:
    """Get the destination configuration from the BigQuery cache."""
    credentials_json: str | None = (
        SecretString(Path(cache.credentials_path).read_text(encoding="utf-8"))
        if cache.credentials_path
        else None
    )
    return DestinationBigquery(
        project_id=cache.project_name,
        dataset_id=cache.dataset_name,
        dataset_location="US",  # <-- Hardcoded
        credentials_json=credentials_json,
        loading_method=BatchedStandardInserts(),
    )

Let's make dataset_location configurable, either by accepting it from the BigQueryConfig object or exposing it as a parameter in the cache setup. This would allow better compatibility with non-US datasets and avoid location mismatch errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions