File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515import datetime
16+ import threading
1617from typing import List , Optional , Sequence
1718import uuid
1819
@@ -40,19 +41,30 @@ def __init__(
4041 ):
4142 self .bqclient = bqclient
4243 self ._location = location
43- self .dataset = bf_io_bigquery .create_bq_dataset_reference (
44- self .bqclient ,
45- location = self ._location ,
46- )
4744
4845 self .session_id = session_id
4946 self ._table_ids : List [bigquery .TableReference ] = []
5047 self ._kms_key = kms_key
5148
49+ self ._dataset_lock = threading .Lock ()
50+ self ._datset_ref : Optional [bigquery .DatasetReference ] = None
51+
5252 @property
5353 def location (self ):
5454 return self ._location
5555
56+ @property
57+ def dataset (self ) -> bigquery .DatasetReference :
58+ if self ._datset_ref is not None :
59+ return self ._datset_ref
60+ with self ._dataset_lock :
61+ if self ._datset_ref is None :
62+ self ._datset_ref = bf_io_bigquery .create_bq_dataset_reference (
63+ self .bqclient ,
64+ location = self ._location ,
65+ )
66+ return self ._datset_ref
67+
5668 def _default_expiration (self ):
5769 """When should the table expire automatically?"""
5870 return (
You can’t perform that action at this time.
0 commit comments