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 1 commit
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
18 changes: 18 additions & 0 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,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
20 changes: 20 additions & 0 deletions bigquery/tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,24 @@ def _verifyResourceProperties(self, job, resource):
else:
self.assertIsNone(job.destination_encryption_configuration)

if "destinationTableDescription" in config:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, _verifyResourceProperties isn't a very good example to follow. I prefer explicitly setting the values you are looking for in the test itself.

Please remove this code and add check for string values for destination_table_description and destination_table_friendly_name to test_ctor_w_config.

self.assertIsNotNone(job.destination_table_description)
self.assertEqual(
job.destination_table_description.description,
config["destinationTableDescription"]["description"],
)
else:
self.assertIsNone(job.destination_table_description)

if "destinationTableFriendlyName" in config:
self.assertIsNotNone(job.destination_table_friendly_name)
self.assertEqual(
job.destination_table_friendly_name.friendly_name,
config["destinationTableFriendlyName"]["friendlyName"],
)
else:
self.assertIsNone(job.destination_table_description)

def test_ctor(self):
client = _make_client(project=self.PROJECT)
job = self._make_one(self.JOB_ID, [self.SOURCE1], self.TABLE_REF, client)
Expand Down Expand Up @@ -1786,6 +1804,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 Down