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
9 changes: 8 additions & 1 deletion bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,8 @@ def wait_for_job(self, job, interval=5, timeout=60):
return job_resource

def push_rows(self, dataset, table, rows, insert_id_key=None,
skip_invalid_rows=None, ignore_unknown_values=None):
skip_invalid_rows=None, ignore_unknown_values=None,
template_suffix=None):
"""Upload rows to BigQuery table.

Parameters
Expand All @@ -1179,6 +1180,9 @@ def push_rows(self, dataset, table, rows, insert_id_key=None,
Insert all valid rows of a request, even if invalid rows exist.
ignore_unknown_values : bool, optional
Accept rows that contain values that do not match the schema.
template_suffix : str, optional
Inserts the rows into an {table}{template_suffix}.
If table {table}{template_suffix} doesn't exist, create from {table}.

Returns
-------
Expand Down Expand Up @@ -1208,6 +1212,9 @@ def push_rows(self, dataset, table, rows, insert_id_key=None,
if ignore_unknown_values is not None:
data['ignoreUnknownValues'] = ignore_unknown_values

if template_suffix is not None:
data['templateSuffix'] = template_suffix

try:
response = table_data.insertAll(
projectId=self.project_id,
Expand Down
5 changes: 4 additions & 1 deletion bigquery/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2176,9 +2176,12 @@ def test_request_data_with_options(self):
self.dataset, self.table, self.rows,
insert_id_key='one',
ignore_unknown_values=True,
skip_invalid_rows=True)
skip_invalid_rows=True,
template_suffix='20160428'
)
expected_body['ignoreUnknownValues'] = True
expected_body['skipInvalidRows'] = True
expected_body['templateSuffix'] = '20160428'
self.mock_table_data.insertAll.assert_called_with(
projectId=self.project,
datasetId=self.dataset,
Expand Down