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 13
13
# limitations under the License.
14
14
15
15
import datetime
16
+ import threading
16
17
from typing import List , Optional , Sequence
17
18
import uuid
18
19
@@ -40,19 +41,30 @@ def __init__(
40
41
):
41
42
self .bqclient = bqclient
42
43
self ._location = location
43
- self .dataset = bf_io_bigquery .create_bq_dataset_reference (
44
- self .bqclient ,
45
- location = self ._location ,
46
- )
47
44
48
45
self .session_id = session_id
49
46
self ._table_ids : List [bigquery .TableReference ] = []
50
47
self ._kms_key = kms_key
51
48
49
+ self ._dataset_lock = threading .Lock ()
50
+ self ._datset_ref : Optional [bigquery .DatasetReference ] = None
51
+
52
52
@property
53
53
def location (self ):
54
54
return self ._location
55
55
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
+
56
68
def _default_expiration (self ):
57
69
"""When should the table expire automatically?"""
58
70
return (
You can’t perform that action at this time.
0 commit comments