From 0d5c4695218bce06267956af1cb5b615aaa433a5 Mon Sep 17 00:00:00 2001 From: Barak Cohen Date: Thu, 3 Mar 2016 15:01:45 +0200 Subject: [PATCH] add a template_suffix parameter to BigQuery Table.insert_data --- gcloud/bigquery/table.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gcloud/bigquery/table.py b/gcloud/bigquery/table.py index dd8e003bc8d5..53bd3cc38700 100644 --- a/gcloud/bigquery/table.py +++ b/gcloud/bigquery/table.py @@ -631,6 +631,7 @@ def insert_data(self, row_ids=None, skip_invalid_rows=None, ignore_unknown_values=None, + template_suffix=None, client=None): """API call: insert table data via a POST request @@ -652,6 +653,13 @@ def insert_data(self, :type ignore_unknown_values: boolean or ``NoneType`` :param ignore_unknown_values: ignore columns beyond schema? + :type template_suffix: string or ``NoneType`` + :param template_suffix: treat ``name`` as a template table and provide + a suffix. BigQuery will create the table + `` + `` based on the + schema of the template table. See: + https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables + :type client: :class:`gcloud.bigquery.client.Client` or ``NoneType`` :param client: the client to use. If not passed, falls back to the ``client`` stored on the current dataset. @@ -689,6 +697,9 @@ def insert_data(self, if ignore_unknown_values is not None: data['ignoreUnknownValues'] = ignore_unknown_values + if template_suffix is not None: + data['templateSuffix'] = template_suffix + response = client.connection.api_request( method='POST', path='%s/insertAll' % self.path,