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

Rename job classes #3797

Merged
merged 2 commits into from
Aug 18, 2017
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
Prev Previous commit
Rename class: 'jobs.ExtractTableToStorageJob' -> 'jobs.ExtractJob'.
  • Loading branch information
tseaver committed Aug 12, 2017
commit 03b708861f80af51fd313847717c2fe140512f52
13 changes: 6 additions & 7 deletions bigquery/google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from google.cloud.bigquery._http import Connection
from google.cloud.bigquery.dataset import Dataset
from google.cloud.bigquery.job import CopyJob
from google.cloud.bigquery.job import ExtractTableToStorageJob
from google.cloud.bigquery.job import ExtractJob
from google.cloud.bigquery.job import LoadJob
from google.cloud.bigquery.job import QueryJob
from google.cloud.bigquery.query import QueryResults
Expand Down Expand Up @@ -171,7 +171,7 @@ def job_from_resource(self, resource):
:rtype: One of:
:class:`google.cloud.bigquery.job.LoadJob`,
:class:`google.cloud.bigquery.job.CopyJob`,
:class:`google.cloud.bigquery.job.ExtractTableToStorageJob`,
:class:`google.cloud.bigquery.job.ExtractJob`,
:class:`google.cloud.bigquery.job.QueryJob`,
:class:`google.cloud.bigquery.job.RunSyncQueryJob`
:returns: the job instance, constructed via the resource
Expand All @@ -182,7 +182,7 @@ def job_from_resource(self, resource):
elif 'copy' in config:
return CopyJob.from_api_repr(resource, self)
elif 'extract' in config:
return ExtractTableToStorageJob.from_api_repr(resource, self)
return ExtractJob.from_api_repr(resource, self)
elif 'query' in config:
return QueryJob.from_api_repr(resource, self)
raise ValueError('Cannot parse job resource')
Expand Down Expand Up @@ -295,11 +295,10 @@ def extract_table_to_storage(self, job_name, source, *destination_uris):
table data is to be extracted; in format
``gs://<bucket_name>/<object_name_or_glob>``.

:rtype: :class:`google.cloud.bigquery.job.ExtractTableToStorageJob`
:returns: a new ``ExtractTableToStorageJob`` instance
:rtype: :class:`google.cloud.bigquery.job.ExtractJob`
:returns: a new ``ExtractJob`` instance
"""
return ExtractTableToStorageJob(job_name, source, destination_uris,
client=self)
return ExtractJob(job_name, source, destination_uris, client=self)

def run_async_query(self, job_name, query,
udf_resources=(), query_parameters=()):
Expand Down
6 changes: 3 additions & 3 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ class _ExtractConfiguration(object):
_print_header = None


class ExtractTableToStorageJob(_AsyncJob):
class ExtractJob(_AsyncJob):
"""Asynchronous job: extract data from a table into Cloud Storage.

:type name: str
Expand All @@ -942,7 +942,7 @@ class ExtractTableToStorageJob(_AsyncJob):
_JOB_TYPE = 'extract'

def __init__(self, name, source, destination_uris, client):
super(ExtractTableToStorageJob, self).__init__(name, client)
super(ExtractJob, self).__init__(name, client)
self.source = source
self.destination_uris = destination_uris
self._configuration = _ExtractConfiguration()
Expand Down Expand Up @@ -1020,7 +1020,7 @@ def from_api_repr(cls, resource, client):
:param client: Client which holds credentials and project
configuration for the dataset.

:rtype: :class:`google.cloud.bigquery.job.ExtractTableToStorageJob`
:rtype: :class:`google.cloud.bigquery.job.ExtractJob`
:returns: Job parsed from ``resource``.
"""
name, config = cls._get_resource_config(resource)
Expand Down
8 changes: 4 additions & 4 deletions bigquery/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def test_list_jobs_defaults(self):
import six
from google.cloud.bigquery.job import LoadJob
from google.cloud.bigquery.job import CopyJob
from google.cloud.bigquery.job import ExtractTableToStorageJob
from google.cloud.bigquery.job import ExtractJob
from google.cloud.bigquery.job import QueryJob

PROJECT = 'PROJECT'
Expand All @@ -225,7 +225,7 @@ def test_list_jobs_defaults(self):
JOB_TYPES = {
'load_job': LoadJob,
'copy_job': CopyJob,
'extract_job': ExtractTableToStorageJob,
'extract_job': ExtractJob,
'query_job': QueryJob,
}
PATH = 'projects/%s/jobs' % PROJECT
Expand Down Expand Up @@ -470,7 +470,7 @@ def test_copy_table(self):
self.assertIs(job.destination, destination)

def test_extract_table_to_storage(self):
from google.cloud.bigquery.job import ExtractTableToStorageJob
from google.cloud.bigquery.job import ExtractJob

PROJECT = 'PROJECT'
JOB = 'job_name'
Expand All @@ -483,7 +483,7 @@ def test_extract_table_to_storage(self):
dataset = client.dataset(DATASET)
source = dataset.table(SOURCE)
job = client.extract_table_to_storage(JOB, source, DESTINATION)
self.assertIsInstance(job, ExtractTableToStorageJob)
self.assertIsInstance(job, ExtractJob)
self.assertIs(job._client, client)
self.assertEqual(job.name, JOB)
self.assertEqual(job.source, source)
Expand Down
8 changes: 4 additions & 4 deletions bigquery/tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,19 +1110,19 @@ def test_reload_w_alternate_client(self):
self._verifyResourceProperties(job, RESOURCE)


class TestExtractTableToStorageJob(unittest.TestCase, _Base):
class TestExtractJob(unittest.TestCase, _Base):
JOB_TYPE = 'extract'
SOURCE_TABLE = 'source_table'
DESTINATION_URI = 'gs://bucket_name/object_name'

@staticmethod
def _get_target_class():
from google.cloud.bigquery.job import ExtractTableToStorageJob
from google.cloud.bigquery.job import ExtractJob

return ExtractTableToStorageJob
return ExtractJob

def _makeResource(self, started=False, ended=False):
resource = super(TestExtractTableToStorageJob, self)._makeResource(
resource = super(TestExtractJob, self)._makeResource(
started, ended)
config = resource['configuration']['extract']
config['sourceTable'] = {
Expand Down