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

BigQuery: Make job.begin() method private. #4242

Merged
merged 1 commit into from
Oct 24, 2017
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
11 changes: 5 additions & 6 deletions bigquery/google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def load_table_from_uri(self, source_uris, destination,
if isinstance(source_uris, six.string_types):
source_uris = [source_uris]
job = LoadJob(job_id, source_uris, destination, self, job_config)
job.begin(retry=retry)
job._begin(retry=retry)
return job

def load_table_from_file(self, file_obj, destination,
Expand Down Expand Up @@ -692,8 +692,7 @@ def load_table_from_file(self, file_obj, destination,
:rtype: :class:`~google.cloud.bigquery.LoadJob`

:returns: the job instance used to load the data (e.g., for
querying status). Note that the job is already started:
do not call ``job.begin()``.
querying status).
:raises: :class:`ValueError` if ``size`` is not passed in and can not
be determined, or if the ``file_obj`` can be detected to be
a file opened in text mode.
Expand Down Expand Up @@ -862,7 +861,7 @@ def copy_table(self, sources, destination, job_id=None, job_id_prefix=None,
sources = [sources]
job = CopyJob(job_id, sources, destination, client=self,
job_config=job_config)
job.begin(retry=retry)
job._begin(retry=retry)
return job

def extract_table(
Expand Down Expand Up @@ -911,7 +910,7 @@ def extract_table(
job = ExtractJob(
job_id, source, destination_uris, client=self,
job_config=job_config)
job.begin(retry=retry)
job._begin(retry=retry)
return job

def query(self, query, job_config=None, job_id=None, job_id_prefix=None,
Expand Down Expand Up @@ -945,7 +944,7 @@ def query(self, query, job_config=None, job_id=None, job_id_prefix=None,
"""
job_id = _make_job_id(job_id, job_id_prefix)
job = QueryJob(job_id, query, client=self, job_config=job_config)
job.begin(retry=retry)
job._begin(retry=retry)
return job

def create_rows(self, table, rows, selected_fields=None, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def _get_resource_config(cls, resource):
config = resource['configuration'][cls._JOB_TYPE]
return job_id, config

def begin(self, client=None, retry=DEFAULT_RETRY):
def _begin(self, client=None, retry=DEFAULT_RETRY):
"""API call: begin the job via a POST request

See
Expand Down Expand Up @@ -521,7 +521,7 @@ def result(self, timeout=None):
given timeout.
"""
if self.state is None:
self.begin()
self._begin()
# TODO: modify PollingFuture so it can pass a retry argument to done().
return super(_AsyncJob, self).result(timeout=timeout)

Expand Down
30 changes: 15 additions & 15 deletions bigquery/tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def test_begin_w_already_running(self):
job._properties['status'] = {'state': 'RUNNING'}

with self.assertRaises(ValueError):
job.begin()
job._begin()

def test_begin_w_bound_client(self):
PATH = '/projects/%s/jobs' % (self.PROJECT,)
Expand All @@ -568,7 +568,7 @@ def test_begin_w_bound_client(self):
job = self._make_one(self.JOB_ID, [self.SOURCE1], self.TABLE_REF,
client)

job.begin()
job._begin()

self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
Expand Down Expand Up @@ -608,7 +608,7 @@ def test_begin_w_autodetect(self):
config.autodetect = True
job = self._make_one(self.JOB_ID, [self.SOURCE1], self.TABLE_REF,
client, config)
job.begin()
job._begin()

sent = {
'jobReference': {
Expand Down Expand Up @@ -688,7 +688,7 @@ def test_begin_w_alternate_client(self):
config.source_format = 'CSV'
config.write_disposition = 'WRITE_TRUNCATE'

job.begin(client=client2)
job._begin(client=client2)

self.assertEqual(len(conn1._requested), 0)
self.assertEqual(len(conn2._requested), 1)
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def test_begin_w_bound_client(self):
destination = self._table_ref(self.DESTINATION_TABLE)
job = self._make_one(self.JOB_ID, [source], destination, client)

job.begin()
job._begin()

self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
Expand Down Expand Up @@ -1077,7 +1077,7 @@ def test_begin_w_alternate_client(self):
config.write_disposition = 'WRITE_TRUNCATE'
job = self._make_one(self.JOB_ID, [source], destination, client1,
config)
job.begin(client=client2)
job._begin(client=client2)

self.assertEqual(len(conn1._requested), 0)
self.assertEqual(len(conn2._requested), 1)
Expand Down Expand Up @@ -1339,7 +1339,7 @@ def test_begin_w_bound_client(self):
job = self._make_one(self.JOB_ID, source, [self.DESTINATION_URI],
client)

job.begin()
job._begin()

self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
Expand Down Expand Up @@ -1394,7 +1394,7 @@ def test_begin_w_alternate_client(self):
job = self._make_one(self.JOB_ID, source, [self.DESTINATION_URI],
client1, job_config)

job.begin(client=client2)
job._begin(client=client2)

self.assertEqual(len(conn1._requested), 0)
self.assertEqual(len(conn2._requested), 1)
Expand Down Expand Up @@ -2243,7 +2243,7 @@ def test_begin_w_bound_client(self):
job = self._make_one(
self.JOB_ID, self.QUERY, client, job_config=config)

job.begin()
job._begin()

self.assertIsNone(job.default_dataset)
self.assertEqual(job.udf_resources, [])
Expand Down Expand Up @@ -2324,7 +2324,7 @@ def test_begin_w_alternate_client(self):
job = self._make_one(
self.JOB_ID, self.QUERY, client1, job_config=config)

job.begin(client=client2)
job._begin(client=client2)

self.assertEqual(len(conn1._requested), 0)
self.assertEqual(len(conn2._requested), 1)
Expand Down Expand Up @@ -2373,7 +2373,7 @@ def test_begin_w_udf(self):
job = self._make_one(
self.JOB_ID, self.QUERY, client, job_config=config)

job.begin()
job._begin()

self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
Expand Down Expand Up @@ -2431,7 +2431,7 @@ def test_begin_w_named_query_parameter(self):
job = self._make_one(
self.JOB_ID, self.QUERY, client, job_config=jconfig)

job.begin()
job._begin()

self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
Expand Down Expand Up @@ -2486,7 +2486,7 @@ def test_begin_w_positional_query_parameter(self):
job = self._make_one(
self.JOB_ID, self.QUERY, client, job_config=jconfig)

job.begin()
job._begin()

self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
Expand Down Expand Up @@ -2572,7 +2572,7 @@ def test_begin_w_table_defs(self):
job = self._make_one(
self.JOB_ID, self.QUERY, client, job_config=config)

job.begin()
job._begin()

self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
Expand Down Expand Up @@ -2615,7 +2615,7 @@ def test_dry_run_query(self):
job = self._make_one(
self.JOB_ID, self.QUERY, client, job_config=config)

job.begin()
job._begin()
self.assertEqual(job.udf_resources, [])
self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
Expand Down