in transcoder/output/google_cloud/BigQueryOutputManager.py [0:0]
def __init__(self, project_id: str, dataset_id, output_prefix: str = None, lazy_create_resources: bool = False):
super().__init__(lazy_create_resources=lazy_create_resources)
self.project_id = project_id
self.dataset_id = dataset_id
self.dataset_ref = bigquery.DatasetReference(project_id, dataset_id)
self.output_prefix = output_prefix
self.client = bigquery.Client(project=project_id)
if self._does_dataset_exist(self.dataset_ref) is False:
self._create_dataset(self.dataset_ref)
else:
dataset = self.client.get_dataset(self.dataset_ref)
if GOOGLE_PACKAGED_SOLUTION_KEY not in dataset.labels or \
dataset.labels.get(GOOGLE_PACKAGED_SOLUTION_KEY, None) != GOOGLE_PACKAGED_SOLUTION_VALUE:
dataset.labels.update(GOOGLE_PACKAGED_SOLUTION_LABEL_DICT)
self.client.update_dataset(dataset, ["labels"])
self.tables = list(self.client.list_tables(dataset_id))
for table_id in list(map(lambda x: x.table_id, self.tables)):
self.existing_schemas.update({table_id: True})