Skip to content

Commit

Permalink
feat(bigquery): implement from_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jul 22, 2024
1 parent ff776cb commit 8556c0c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions ibis/backends/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8556c0c

Please sign in to comment.