We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Improve guidance for streaming inserts
Suggesting we update the insert_rows.py code to showcase how to explicitly define a schema to avoid excessive calls to get_table().

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `samples/table_insert_rows.py`
Content:
```
1 # Copyright 2019 Google LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     https://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 
16 def table_insert_rows(table_id):
17 
18     # [START bigquery_table_insert_rows]
19 
20     from google.cloud import bigquery
21 
22     # Construct a BigQuery client object.
23     client = bigquery.Client()
24 
25     # TODO(developer): Set table_id to the ID of the model to fetch.
26     # table_id = "your-project.your_dataset.your_table"
27 
28     table = client.get_table(table_id)  # Make an API request.
29     rows_to_insert = [(u"Phred Phlyntstone", 32), (u"Wylma Phlyntstone", 29)]
30 
31     errors = client.insert_rows(table, rows_to_insert)  # Make an API request.
32     if errors == []:
33         print("New rows have been added.")
34     # [END bigquery_table_insert_rows]
35
```

Path: `samples/table_insert_rows_explicit_none_insert_ids.py`
Content:
```
1 # Copyright 2019 Google LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     https://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 
16 def table_insert_rows_explicit_none_insert_ids(table_id):
17 
18     # [START bigquery_table_insert_rows_explicit_none_insert_ids]
19 
20     from google.cloud import bigquery
21 
22     # Construct a BigQuery client object.
23     client = bigquery.Client()
24 
25     # TODO(developer): Set table_id to the ID of the model to fetch.
26     # table_id = "your-project.your_dataset.your_table"
27 
28     table = client.get_table(table_id)  # Make an API request.
29     rows_to_insert = [(u"Phred Phlyntstone", 32), (u"Wylma Phlyntstone", 29)]
30 
31     errors = client.insert_rows(
32         table, rows_to_insert, row_ids=[None] * len(rows_to_insert)
33     )  # Make an API request.
34     if errors == []:
35         print("New rows have been added.")
36     # [END bigquery_table_insert_rows_explicit_none_insert_ids]
37
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/samples/table_insert_rows.py b/samples/table_insert_rows.py
--- a/samples/table_insert_rows.py
+++ b/samples/table_insert_rows.py
@@ -16,19 +16,22 @@
 def table_insert_rows(table_id):
 
     # [START bigquery_table_insert_rows]
-
     from google.cloud import bigquery
 
     # Construct a BigQuery client object.
     client = bigquery.Client()
 
-    # TODO(developer): Set table_id to the ID of the model to fetch.
+    # TODO(developer): Set table_id to the ID of table to append to.
     # table_id = "your-project.your_dataset.your_table"
 
-    table = client.get_table(table_id)  # Make an API request.
-    rows_to_insert = [(u"Phred Phlyntstone", 32), (u"Wylma Phlyntstone", 29)]
+    rows_to_insert = [
+        {u"full_name": u"Phred Phlyntstone", u"age": 32},
+        {u"full_name": u"Wylma Phlyntstone", u"age": 29},
+    ]
 
-    errors = client.insert_rows(table, rows_to_insert)  # Make an API request.
+    errors = client.insert_rows_json(table_id, rows_to_insert)  # Make an API request.
     if errors == []:
         print("New rows have been added.")
+    else:
+        print("Encountered errors while inserting rows: {}".format(errors))
     # [END bigquery_table_insert_rows]
diff --git a/samples/table_insert_rows_explicit_none_insert_ids.py b/samples/table_insert_rows_explicit_none_insert_ids.py
--- a/samples/table_insert_rows_explicit_none_insert_ids.py
+++ b/samples/table_insert_rows_explicit_none_insert_ids.py
@@ -16,21 +16,24 @@
 def table_insert_rows_explicit_none_insert_ids(table_id):
 
     # [START bigquery_table_insert_rows_explicit_none_insert_ids]
-
     from google.cloud import bigquery
 
     # Construct a BigQuery client object.
     client = bigquery.Client()
 
-    # TODO(developer): Set table_id to the ID of the model to fetch.
+    # TODO(developer): Set table_id to the ID of table to append to.
     # table_id = "your-project.your_dataset.your_table"
 
-    table = client.get_table(table_id)  # Make an API request.
-    rows_to_insert = [(u"Phred Phlyntstone", 32), (u"Wylma Phlyntstone", 29)]
+    rows_to_insert = [
+        {u"full_name": u"Phred Phlyntstone", u"age": 32},
+        {u"full_name": u"Wylma Phlyntstone", u"age": 29},
+    ]
 
-    errors = client.insert_rows(
-        table, rows_to_insert, row_ids=[None] * len(rows_to_insert)
+    errors = client.insert_rows_json(
+        table_id, rows_to_insert, row_ids=[None] * len(rows_to_insert)
     )  # Make an API request.
     if errors == []:
         print("New rows have been added.")
+    else:
+        print("Encountered errors while inserting rows: {}".format(errors))
     # [END bigquery_table_insert_rows_explicit_none_insert_ids]

{"golden_diff": "diff --git a/samples/table_insert_rows.py b/samples/table_insert_rows.py\n--- a/samples/table_insert_rows.py\n+++ b/samples/table_insert_rows.py\n@@ -16,19 +16,22 @@\n def table_insert_rows(table_id):\n \n     # [START bigquery_table_insert_rows]\n-\n     from google.cloud import bigquery\n \n     # Construct a BigQuery client object.\n     client = bigquery.Client()\n \n-    # TODO(developer): Set table_id to the ID of the model to fetch.\n+    # TODO(developer): Set table_id to the ID of table to append to.\n     # table_id = \"your-project.your_dataset.your_table\"\n \n-    table = client.get_table(table_id)  # Make an API request.\n-    rows_to_insert = [(u\"Phred Phlyntstone\", 32), (u\"Wylma Phlyntstone\", 29)]\n+    rows_to_insert = [\n+        {u\"full_name\": u\"Phred Phlyntstone\", u\"age\": 32},\n+        {u\"full_name\": u\"Wylma Phlyntstone\", u\"age\": 29},\n+    ]\n \n-    errors = client.insert_rows(table, rows_to_insert)  # Make an API request.\n+    errors = client.insert_rows_json(table_id, rows_to_insert)  # Make an API request.\n     if errors == []:\n         print(\"New rows have been added.\")\n+    else:\n+        print(\"Encountered errors while inserting rows: {}\".format(errors))\n     # [END bigquery_table_insert_rows]\ndiff --git a/samples/table_insert_rows_explicit_none_insert_ids.py b/samples/table_insert_rows_explicit_none_insert_ids.py\n--- a/samples/table_insert_rows_explicit_none_insert_ids.py\n+++ b/samples/table_insert_rows_explicit_none_insert_ids.py\n@@ -16,21 +16,24 @@\n def table_insert_rows_explicit_none_insert_ids(table_id):\n \n     # [START bigquery_table_insert_rows_explicit_none_insert_ids]\n-\n     from google.cloud import bigquery\n \n     # Construct a BigQuery client object.\n     client = bigquery.Client()\n \n-    # TODO(developer): Set table_id to the ID of the model to fetch.\n+    # TODO(developer): Set table_id to the ID of table to append to.\n     # table_id = \"your-project.your_dataset.your_table\"\n \n-    table = client.get_table(table_id)  # Make an API request.\n-    rows_to_insert = [(u\"Phred Phlyntstone\", 32), (u\"Wylma Phlyntstone\", 29)]\n+    rows_to_insert = [\n+        {u\"full_name\": u\"Phred Phlyntstone\", u\"age\": 32},\n+        {u\"full_name\": u\"Wylma Phlyntstone\", u\"age\": 29},\n+    ]\n \n-    errors = client.insert_rows(\n-        table, rows_to_insert, row_ids=[None] * len(rows_to_insert)\n+    errors = client.insert_rows_json(\n+        table_id, rows_to_insert, row_ids=[None] * len(rows_to_insert)\n     )  # Make an API request.\n     if errors == []:\n         print(\"New rows have been added.\")\n+    else:\n+        print(\"Encountered errors while inserting rows: {}\".format(errors))\n     # [END bigquery_table_insert_rows_explicit_none_insert_ids]\n", "issue": "Improve guidance for streaming inserts\nSuggesting we update the insert_rows.py code to showcase how to explicitly define a schema to avoid excessive calls to get_table().\n", "before_files": [{"content": "# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\ndef table_insert_rows(table_id):\n\n    # [START bigquery_table_insert_rows]\n\n    from google.cloud import bigquery\n\n    # Construct a BigQuery client object.\n    client = bigquery.Client()\n\n    # TODO(developer): Set table_id to the ID of the model to fetch.\n    # table_id = \"your-project.your_dataset.your_table\"\n\n    table = client.get_table(table_id)  # Make an API request.\n    rows_to_insert = [(u\"Phred Phlyntstone\", 32), (u\"Wylma Phlyntstone\", 29)]\n\n    errors = client.insert_rows(table, rows_to_insert)  # Make an API request.\n    if errors == []:\n        print(\"New rows have been added.\")\n    # [END bigquery_table_insert_rows]\n", "path": "samples/table_insert_rows.py"}, {"content": "# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\ndef table_insert_rows_explicit_none_insert_ids(table_id):\n\n    # [START bigquery_table_insert_rows_explicit_none_insert_ids]\n\n    from google.cloud import bigquery\n\n    # Construct a BigQuery client object.\n    client = bigquery.Client()\n\n    # TODO(developer): Set table_id to the ID of the model to fetch.\n    # table_id = \"your-project.your_dataset.your_table\"\n\n    table = client.get_table(table_id)  # Make an API request.\n    rows_to_insert = [(u\"Phred Phlyntstone\", 32), (u\"Wylma Phlyntstone\", 29)]\n\n    errors = client.insert_rows(\n        table, rows_to_insert, row_ids=[None] * len(rows_to_insert)\n    )  # Make an API request.\n    if errors == []:\n        print(\"New rows have been added.\")\n    # [END bigquery_table_insert_rows_explicit_none_insert_ids]\n", "path": "samples/table_insert_rows_explicit_none_insert_ids.py"}], "after_files": [{"content": "# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\ndef table_insert_rows(table_id):\n\n    # [START bigquery_table_insert_rows]\n    from google.cloud import bigquery\n\n    # Construct a BigQuery client object.\n    client = bigquery.Client()\n\n    # TODO(developer): Set table_id to the ID of table to append to.\n    # table_id = \"your-project.your_dataset.your_table\"\n\n    rows_to_insert = [\n        {u\"full_name\": u\"Phred Phlyntstone\", u\"age\": 32},\n        {u\"full_name\": u\"Wylma Phlyntstone\", u\"age\": 29},\n    ]\n\n    errors = client.insert_rows_json(table_id, rows_to_insert)  # Make an API request.\n    if errors == []:\n        print(\"New rows have been added.\")\n    else:\n        print(\"Encountered errors while inserting rows: {}\".format(errors))\n    # [END bigquery_table_insert_rows]\n", "path": "samples/table_insert_rows.py"}, {"content": "# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\ndef table_insert_rows_explicit_none_insert_ids(table_id):\n\n    # [START bigquery_table_insert_rows_explicit_none_insert_ids]\n    from google.cloud import bigquery\n\n    # Construct a BigQuery client object.\n    client = bigquery.Client()\n\n    # TODO(developer): Set table_id to the ID of table to append to.\n    # table_id = \"your-project.your_dataset.your_table\"\n\n    rows_to_insert = [\n        {u\"full_name\": u\"Phred Phlyntstone\", u\"age\": 32},\n        {u\"full_name\": u\"Wylma Phlyntstone\", u\"age\": 29},\n    ]\n\n    errors = client.insert_rows_json(\n        table_id, rows_to_insert, row_ids=[None] * len(rows_to_insert)\n    )  # Make an API request.\n    if errors == []:\n        print(\"New rows have been added.\")\n    else:\n        print(\"Encountered errors while inserting rows: {}\".format(errors))\n    # [END bigquery_table_insert_rows_explicit_none_insert_ids]\n", "path": "samples/table_insert_rows_explicit_none_insert_ids.py"}]}