Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
770b560
Avoid importing module-/package-under-test at testcase module scope.
tseaver Jul 18, 2018
d8859b4
Add explict unit tests for 'job._JobReference'.
tseaver Jul 18, 2018
8c48c79
Add explicit unit tests for '_AsyncJob' ctor and read-only properties.
tseaver Jul 18, 2018
64453b4
Add explicit unit tests for '_AsyncJob._set_properties' and helpers.
tseaver Jul 18, 2018
0b6f7d7
Add explict unit tests for '_AsyncJob._get_resource_config'.
tseaver Jul 18, 2018
7dceb43
Note '_AsyncJob._build_resource' explicitly as an abstract method.
tseaver Jul 18, 2018
4ba5dc9
Add explicit unit tests for '_AsyncJob._begin'.
tseaver Jul 18, 2018
ad31f21
Add explicit unit tests for '_AsyncJob.exists'.
tseaver Jul 18, 2018
8628ca5
Add explicit unit tests for '_AsyncJob.reload'.
tseaver Jul 18, 2018
d47e7ff
Add explicit unit tests for '_AsyncJob.cancel'.
tseaver Jul 19, 2018
1f8fcc3
Add explicit unit tests for '_AsyncJob._set_future_result'.
tseaver Jul 19, 2018
af94667
Add explicit unit tests for '_AsyncJob.done'.
tseaver Jul 19, 2018
8f63531
Add explicit unit tests for '_AsyncJob.resuit'.
tseaver Jul 19, 2018
16f4d6a
Add explicit unit tests for '_AsyncJob.cancelled'.
tseaver Jul 19, 2018
752c74a
Add explicit unit test for '_JobConfig' ctor.
tseaver Jul 19, 2018
9003cf0
Add explicit unit tests for '_JobConfig._{get,set}_sub_prop'.
tseaver Jul 19, 2018
3ee7d8c
Add explicit unit test for '_JobConfig.to_api_repr'.
tseaver Jul 19, 2018
515a0f5
Note why '_JobConfig.from_api_repr' is not tested directly.
tseaver Jul 19, 2018
d7eeccb
Add 'QueryJob.estimated_bytes_proceesed' property.
tseaver Jul 19, 2018
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
28 changes: 24 additions & 4 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,10 @@ def _get_resource_config(cls, resource):
'["configuration"]["%s"]' % cls._JOB_TYPE)
return job_id, resource['configuration']

def _build_resource(self):
"""Helper: Generate a resource for :meth:`_begin`."""
raise NotImplementedError("Abstract")

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

Expand Down Expand Up @@ -1237,7 +1241,7 @@ def output_rows(self):
return int(statistics['load']['outputRows'])

def _build_resource(self):
"""Generate a resource for :meth:`begin`."""
"""Generate a resource for :meth:`_begin`."""
configuration = self._configuration.to_api_repr()
if self.source_uris is not None:
_helpers._set_sub_prop(
Expand Down Expand Up @@ -1413,7 +1417,7 @@ def destination_encryption_configuration(self):
return self._configuration.destination_encryption_configuration

def _build_resource(self):
"""Generate a resource for :meth:`begin`."""
"""Generate a resource for :meth:`_begin`."""

source_refs = [{
'projectId': table.project,
Expand Down Expand Up @@ -1631,7 +1635,7 @@ def destination_uri_file_counts(self):
return None

def _build_resource(self):
"""Generate a resource for :meth:`begin`."""
"""Generate a resource for :meth:`_begin`."""

source_ref = {
'projectId': self.source.project,
Expand Down Expand Up @@ -2202,7 +2206,7 @@ def schema_update_options(self):
return self._configuration.schema_update_options

def _build_resource(self):
"""Generate a resource for :meth:`begin`."""
"""Generate a resource for :meth:`_begin`."""
configuration = self._configuration.to_api_repr()

resource = {
Expand Down Expand Up @@ -2437,6 +2441,22 @@ def undeclared_query_parameters(self):

return parameters

@property
def estimated_bytes_processed(self):
"""Return the estimated number of bytes processed by the query.

See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.estimatedBytesProcessed

:rtype: int or None
:returns: number of DML rows affected by the job, or None if job is not
yet complete.
"""
result = self._job_statistics().get('estimatedBytesProcessed')
if result is not None:
result = int(result)
return result

def done(self, retry=DEFAULT_RETRY):
"""Refresh the job and checks if it is complete.

Expand Down
Loading