@@ -408,7 +408,7 @@ def create_empty_dataset(
408
408
location : Optional [str ] = None ,
409
409
dataset_reference : Optional [Dict [str , Any ]] = None ,
410
410
exists_ok : bool = True ,
411
- ) -> None :
411
+ ) -> Dict [ str , Any ] :
412
412
"""
413
413
Create a new empty dataset:
414
414
https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/insert
@@ -452,8 +452,11 @@ def create_empty_dataset(
452
452
453
453
dataset : Dataset = Dataset .from_api_repr (dataset_reference )
454
454
self .log .info ('Creating dataset: %s in project: %s ' , dataset .dataset_id , dataset .project )
455
- self .get_client (location = location ).create_dataset (dataset = dataset , exists_ok = exists_ok )
455
+ dataset_object = self .get_client (location = location ).create_dataset (
456
+ dataset = dataset , exists_ok = exists_ok
457
+ )
456
458
self .log .info ('Dataset created successfully.' )
459
+ return dataset_object .to_api_repr ()
457
460
458
461
@GoogleBaseHook .fallback_to_default_project_id
459
462
def get_dataset_tables (
@@ -533,7 +536,7 @@ def create_external_table(
533
536
encryption_configuration : Optional [Dict ] = None ,
534
537
location : Optional [str ] = None ,
535
538
project_id : Optional [str ] = None ,
536
- ) -> None :
539
+ ) -> Table :
537
540
"""
538
541
Creates a new external table in the dataset with the data from Google
539
542
Cloud Storage. See here:
@@ -659,10 +662,11 @@ def create_external_table(
659
662
table .encryption_configuration = EncryptionConfiguration .from_api_repr (encryption_configuration )
660
663
661
664
self .log .info ('Creating external table: %s' , external_project_dataset_table )
662
- self .create_empty_table (
665
+ table_object = self .create_empty_table (
663
666
table_resource = table .to_api_repr (), project_id = project_id , location = location , exists_ok = True
664
667
)
665
668
self .log .info ('External table created successfully: %s' , external_project_dataset_table )
669
+ return table_object
666
670
667
671
@GoogleBaseHook .fallback_to_default_project_id
668
672
def update_table (
@@ -1287,7 +1291,7 @@ def update_table_schema(
1287
1291
dataset_id : str ,
1288
1292
table_id : str ,
1289
1293
project_id : Optional [str ] = None ,
1290
- ) -> None :
1294
+ ) -> Dict [ str , Any ] :
1291
1295
"""
1292
1296
Update fields within a schema for a given dataset and table. Note that
1293
1297
some fields in schemas are immutable and trying to change them will cause
@@ -1361,13 +1365,14 @@ def _remove_policy_tags(schema: List[Dict[str, Any]]):
1361
1365
if not include_policy_tags :
1362
1366
_remove_policy_tags (new_schema )
1363
1367
1364
- self .update_table (
1368
+ table = self .update_table (
1365
1369
table_resource = {"schema" : {"fields" : new_schema }},
1366
1370
fields = ["schema" ],
1367
1371
project_id = project_id ,
1368
1372
dataset_id = dataset_id ,
1369
1373
table_id = table_id ,
1370
1374
)
1375
+ return table
1371
1376
1372
1377
@GoogleBaseHook .fallback_to_default_project_id
1373
1378
def poll_job_complete (
@@ -2244,7 +2249,7 @@ def create_empty_table(self, *args, **kwargs) -> None:
2244
2249
)
2245
2250
return self .hook .create_empty_table (* args , ** kwargs )
2246
2251
2247
- def create_empty_dataset (self , * args , ** kwargs ) -> None :
2252
+ def create_empty_dataset (self , * args , ** kwargs ) -> Dict [ str , Any ] :
2248
2253
"""
2249
2254
This method is deprecated.
2250
2255
Please use `airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.create_empty_dataset`
0 commit comments