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

        Parameters
        ----------
        dataset : str
            The dataset to upload to
        table : str
            The name of the table to insert rows into
        rows : list
            A ``list`` of rows (``dict`` objects) to add to the table
        insert_id_key : str, optional
            Key for insertId in row
        skip_invalid_rows : bool, optional
            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
        -------
        Union[bool, dict]
            bool indicating if insert succeeded or not, or response
            from BigQuery if swallow_results is set for False.
        """

        table_data = self.bigquery.tabledata()

        rows_data = []
        for row in rows:
            each_row = {}
            each_row["json"] = row
            if insert_id_key in row:
                each_row["insertId"] = row[insert_id_key]
            rows_data.append(each_row)

        data = {
            "kind": "bigquery#tableDataInsertAllRequest",
            "rows": rows_data
        }

        if skip_invalid_rows is not None:
            data['skipInvalidRows'] = skip_invalid_rows

        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,
                datasetId=dataset,
                tableId=table,
                body=data
            ).execute()

            if response.get('insertErrors'):
                logger.error('BigQuery insert errors: %s' % response)
                if self.swallow_results:
                    return False
                else:
                    return response

            if self.swallow_results:
                return True
            else:
                return response

        except HttpError as e:
            logger.exception('Problem with BigQuery insertAll')
            if self.swallow_results:
                return False
            else:
                return {
                    'insertErrors': [{
                        'errors': [{
                            'reason': 'httperror',
                            'message': e
                        }]
                    }]
                }
dataset/ETHPy150Open tylertreat/BigQuery-Python/bigquery/client.py/BigQueryClient.push_rows/original