Skip to content

Commit 39de0c6

Browse files
author
Jerjou Cheng
committed
insertId is within the row, not the request.
Fixes bug #134
1 parent 1ff6a5b commit 39de0c6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bigquery/api/streaming.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
# [START stream_row_to_bigquery]
3636
def stream_row_to_bigquery(bigquery, project_id, dataset_id, table_name, row,
3737
num_retries=5):
38-
# Generate a unique row id so retries
39-
# don't accidentally duplicate insert
4038
insert_all_data = {
41-
'insertId': str(uuid.uuid4()),
42-
'rows': [{'json': row}]
39+
'rows': [{
40+
'json': row,
41+
# Generate a unique id for each row so retries don't accidentally
42+
# duplicate insert
43+
'insertId': str(uuid.uuid4()),
44+
}]
4345
}
4446
return bigquery.tabledata().insertAll(
4547
projectId=project_id,

0 commit comments

Comments
 (0)