Skip to content

Commit 785c907

Browse files
lbristol88tswast
authored andcommitted
Adding missing properties from LoadJobConfig to LoadJob library (googleapis#7710)
* Added new properties to LoadJob that are in LoadJobConfig. * Added destination property and updated tests per feedback.
1 parent a9e346f commit 785c907

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

bigquery/google/cloud/bigquery/job.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,9 +1257,18 @@ def __init__(self, job_id, source_uris, destination, client, job_config=None):
12571257
job_config = LoadJobConfig()
12581258

12591259
self.source_uris = source_uris
1260-
self.destination = destination
1260+
self._destination = destination
12611261
self._configuration = job_config
12621262

1263+
@property
1264+
def destination(self):
1265+
"""google.cloud.bigquery.table.TableReference: table where loaded rows are written
1266+
1267+
See:
1268+
https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.load.destinationTable
1269+
"""
1270+
return self._destination
1271+
12631272
@property
12641273
def allow_jagged_rows(self):
12651274
"""See
@@ -1371,6 +1380,24 @@ def destination_encryption_configuration(self):
13711380
"""
13721381
return self._configuration.destination_encryption_configuration
13731382

1383+
@property
1384+
def destination_table_description(self):
1385+
"""Union[str, None] name given to destination table.
1386+
1387+
See:
1388+
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.destinationTableProperties.description
1389+
"""
1390+
return self._configuration.destination_table_description
1391+
1392+
@property
1393+
def destination_table_friendly_name(self):
1394+
"""Union[str, None] name given to destination table.
1395+
1396+
See:
1397+
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.destinationTableProperties.friendlyName
1398+
"""
1399+
return self._configuration.destination_table_friendly_name
1400+
13741401
@property
13751402
def time_partitioning(self):
13761403
"""See

bigquery/tests/unit/test_job.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,8 @@ def test_ctor(self):
17861786
self.assertIsNone(job.source_format)
17871787
self.assertIsNone(job.write_disposition)
17881788
self.assertIsNone(job.destination_encryption_configuration)
1789+
self.assertIsNone(job.destination_table_description)
1790+
self.assertIsNone(job.destination_table_friendly_name)
17891791
self.assertIsNone(job.time_partitioning)
17901792
self.assertIsNone(job.use_avro_logical_types)
17911793
self.assertIsNone(job.clustering_fields)
@@ -1804,6 +1806,16 @@ def test_ctor_w_config(self):
18041806
self.JOB_ID, [self.SOURCE1], self.TABLE_REF, client, config
18051807
)
18061808
self.assertEqual(job.schema, [full_name, age])
1809+
config.destination_table_description = "Description"
1810+
expected = {"description": "Description"}
1811+
self.assertEqual(
1812+
config._properties["load"]["destinationTableProperties"], expected
1813+
)
1814+
friendly_name = "Friendly Name"
1815+
config._properties["load"]["destinationTableProperties"] = {
1816+
"friendlyName": friendly_name
1817+
}
1818+
self.assertEqual(config.destination_table_friendly_name, friendly_name)
18071819

18081820
def test_ctor_w_job_reference(self):
18091821
from google.cloud.bigquery import job

0 commit comments

Comments
 (0)