Skip to content
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
25 changes: 15 additions & 10 deletions bigquery/google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from google.resumable_media.requests import ResumableUpload

from google.api_core import page_iterator
import google.cloud._helpers
from google.cloud import exceptions
from google.cloud.client import ClientWithProject

Expand Down Expand Up @@ -692,14 +693,14 @@ def list_jobs(
* ``"running"``
retry (google.api_core.retry.Retry, optional):
How to retry the RPC.
min_creation_time (int, optional):
Min value for job creation time, in milliseconds since the
POSIX epoch. If set, only jobs created after or at this
timestamp are returned.
max_creation_time (int, optional):
Max value for job creation time, in milliseconds since the
POSIX epoch. If set, only jobs created before or at this
timestamp are returned.
min_creation_time (datetitme.datetime, optional):
Min value for job creation time. If set, only jobs created
after or at this timestamp are returned. If the datetime has
no time zone assumes UTC time.
max_creation_time (datetime.datetime, optional):
Max value for job creation time. If set, only jobs created
before or at this timestamp are returned. If the datetime has
no time zone assumes UTC time.

Returns:
google.api_core.page_iterator.Iterator:
Expand All @@ -708,8 +709,12 @@ def list_jobs(
extra_params = {
'allUsers': all_users,
'stateFilter': state_filter,
'minCreationTime': _str_or_none(min_creation_time),
'maxCreationTime': _str_or_none(max_creation_time),
'minCreationTime': _str_or_none(
google.cloud._helpers._millis_from_datetime(
min_creation_time)),
'maxCreationTime': _str_or_none(
google.cloud._helpers._millis_from_datetime(
max_creation_time)),
'projection': 'full'
}

Expand Down
11 changes: 9 additions & 2 deletions bigquery/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import copy
import datetime
import decimal
import email
import io
Expand Down Expand Up @@ -1758,16 +1759,22 @@ def test_list_jobs_w_time_filter(self):
client = self._make_one(self.PROJECT, creds)
conn = client._connection = _make_connection({})

# One millisecond after the unix epoch.
start_time = datetime.datetime(1970, 1, 1, 0, 0, 0, 1000)
# One millisecond after the the 2038 31-bit signed int rollover
end_time = datetime.datetime(2038, 1, 19, 3, 14, 7, 1000)
end_time_millis = (((2 ** 31) - 1) * 1000) + 1

list(client.list_jobs(
min_creation_time=1, max_creation_time=1527874895820))
min_creation_time=start_time, max_creation_time=end_time))

conn.api_request.assert_called_once_with(
method='GET',
path='/projects/%s/jobs' % self.PROJECT,
query_params={
'projection': 'full',
'minCreationTime': '1',
'maxCreationTime': '1527874895820',
'maxCreationTime': str(end_time_millis),
})

def test_load_table_from_uri(self):
Expand Down