Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing properties from LoadJobConfig to LoadJob library #7710

Merged
merged 4 commits into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,9 +1257,18 @@ def __init__(self, job_id, source_uris, destination, client, job_config=None):
job_config = LoadJobConfig()

self.source_uris = source_uris
self.destination = destination
self._destination = destination
self._configuration = job_config

@property
def destination(self):
"""google.cloud.bigquery.table.TableReference: table where loaded rows are written

See:
https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.load.destinationTable
"""
return self._destination

@property
def allow_jagged_rows(self):
"""See
Expand Down Expand Up @@ -1371,6 +1380,24 @@ def destination_encryption_configuration(self):
"""
return self._configuration.destination_encryption_configuration

@property
def destination_table_description(self):
"""Union[str, None] name given to destination table.

See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.destinationTableProperties.description
"""
return self._configuration.destination_table_description

@property
def destination_table_friendly_name(self):
"""Union[str, None] name given to destination table.

See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.destinationTableProperties.friendlyName
"""
return self._configuration.destination_table_friendly_name

@property
def time_partitioning(self):
"""See
Expand Down
12 changes: 12 additions & 0 deletions bigquery/tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1786,6 +1786,8 @@ def test_ctor(self):
self.assertIsNone(job.source_format)
self.assertIsNone(job.write_disposition)
self.assertIsNone(job.destination_encryption_configuration)
self.assertIsNone(job.destination_table_description)
self.assertIsNone(job.destination_table_friendly_name)
self.assertIsNone(job.time_partitioning)
self.assertIsNone(job.use_avro_logical_types)
self.assertIsNone(job.clustering_fields)
Expand All @@ -1804,6 +1806,16 @@ def test_ctor_w_config(self):
self.JOB_ID, [self.SOURCE1], self.TABLE_REF, client, config
)
self.assertEqual(job.schema, [full_name, age])
config.destination_table_description = "Description"
expected = {"description": "Description"}
self.assertEqual(
config._properties["load"]["destinationTableProperties"], expected
)
friendly_name = "Friendly Name"
config._properties["load"]["destinationTableProperties"] = {
"friendlyName": friendly_name
}
self.assertEqual(config.destination_table_friendly_name, friendly_name)

def test_ctor_w_job_reference(self):
from google.cloud.bigquery import job
Expand Down