8000 perf: Faster session startup by defering anon dataset fetch by TrevorBergeron · Pull Request #1982 · googleapis/python-bigquery-dataframes · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions bigframes/session/anonymous_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import datetime
import threading
from typing import List, Optional, Sequence
import uuid

Expand Down Expand Up @@ -40,19 +41,30 @@ def __init__(
):
self.bqclient = bqclient
self._location = location
self.dataset = bf_io_bigquery.create_bq_dataset_reference(
self.bqclient,
location=self._location,
)

self.session_id = session_id
self._table_ids: List[bigquery.TableReference] = []
self._kms_key = kms_key

self._dataset_lock = threading.Lock()
self._datset_ref: Optional[bigquery.DatasetReference] = None

@property
def location(self):
return self._location

@property
def dataset(self) -> bigquery.DatasetReference:
if self._datset_ref is not None:
return self._datset_ref
with self._dataset_lock:
if self._datset_ref is None:
self._datset_ref = bf_io_bigquery.create_bq_dataset_reference(
self.bqclient,
location=self._location,
)
return self._datset_ref

def _default_expiration(self):
"""When should the table expire automatically?"""
return (
Expand Down
0