From 8556c0cacf099bcb5110ec6b013cdfda0c4a21f5 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 22 Jul 2024 15:58:02 -0400 Subject: [PATCH] feat(bigquery): implement `from_connection` --- ibis/backends/bigquery/__init__.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ibis/backends/bigquery/__init__.py b/ibis/backends/bigquery/__init__.py index bbbc5cfe5e645..738a430cf88cf 100644 --- a/ibis/backends/bigquery/__init__.py +++ b/ibis/backends/bigquery/__init__.py @@ -485,26 +485,31 @@ def from_connection( client: bq.Client, partition_column: str | None = "PARTITIONTIME", storage_client: bqstorage.BigQueryReadClient | None = None, + dataset_id: str = "", ) -> Backend: """Create a BigQuery `Backend` from an existing ``Client``. Parameters ---------- client - A ``Client`` from the ``google.cloud.bigquery`` package. + A `Client` from the `google.cloud.bigquery` package. partition_column - Identifier to use instead of default ``_PARTITIONTIME`` partition - column. Defaults to ``'PARTITIONTIME'``. + Identifier to use instead of default `_PARTITIONTIME` partition + column. Defaults to `'PARTITIONTIME'`. storage_client - A ``BigQueryReadClient`` from the - ``google.cloud.bigquery_storage_v1`` package. If not set, one is - created using the ``project_id`` and ``credentials``. + A `BigQueryReadClient` from the `google.cloud.bigquery_storage_v1` + package. + dataset_id + A dataset id that lives inside of the project attached to `client`. """ - return ibis.bigquery.Backend.connect( + con = ibis.bigquery.connect( client=client, partition_column=partition_column, storage_client=storage_client, + dataset_id=dataset_id, ) + con._can_reconnect = False + return con def disconnect(self) -> None: self.client.close()