Skip to content

Commit

Permalink
perf(bigquery): avoid running list_tables when registering memtables (
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Jun 21, 2024
1 parent 4dff6e2 commit fbc79d2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ibis/backends/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import TYPE_CHECKING, Any, Optional
from urllib.parse import parse_qs, urlparse

import google.api_core.exceptions
import google.auth.credentials
import google.cloud.bigquery as bq
import google.cloud.bigquery_storage_v1 as bqstorage
Expand Down Expand Up @@ -171,10 +172,14 @@ def _session_dataset(self):
def _register_in_memory_table(self, op: ops.InMemoryTable) -> None:
raw_name = op.name

project = self._session_dataset.project
dataset = self._session_dataset.dataset_id
session_dataset = self._session_dataset
project = session_dataset.project
dataset = session_dataset.dataset_id

if raw_name not in self.list_tables(database=(project, dataset)):
table_ref = bq.TableReference(session_dataset, raw_name)
try:
self.client.get_table(table_ref)
except google.api_core.exceptions.NotFound:
table_id = sg.table(
raw_name, db=dataset, catalog=project, quoted=False
).sql(dialect=self.name)
Expand Down

0 comments on commit fbc79d2

Please sign in to comment.