@@ -92,10 +92,8 @@ def test_client_library_legacy_query():
92
92
WHERE state = 'TX'
93
93
LIMIT 100
94
94
"""
95
- query_config = bigquery .QueryJobConfig ()
96
- query_config .use_legacy_sql = True
95
+ query_config = bigquery .QueryJobConfig (use_legacy_sql = True )
97
96
98
- # Run a Standard SQL query using the environment's default project
99
97
df = client .query (sql , job_config = query_config ).to_dataframe ()
100
98
# [END bigquery_migration_client_library_query_legacy]
101
99
assert len (df ) > 0
@@ -128,11 +126,13 @@ def test_client_library_query_with_parameters():
128
126
WHERE state = @state
129
127
LIMIT @limit
130
128
"""
131
- query_config = bigquery .QueryJobConfig ()
132
- query_config .query_parameters = [
133
- bigquery .ScalarQueryParameter ('state' , 'STRING' , 'TX' ),
134
- bigquery .ScalarQueryParameter ('limit' , 'INTEGER' , 100 )
135
- ]
129
+ query_config = bigquery .QueryJobConfig (
130
+ query_parameters = [
131
+ bigquery .ScalarQueryParameter ('state' , 'STRING' , 'TX' ),
132
+ bigquery .ScalarQueryParameter ('limit' , 'INTEGER' , 100 )
133
+ ]
134
+ )
135
+
136
136
df = client .query (sql , job_config = query_config ).to_dataframe ()
137
137
# [END bigquery_migration_client_library_query_parameters]
138
138
assert len (df ) > 0
@@ -165,6 +165,7 @@ def test_pandas_gbq_query_with_parameters():
165
165
]
166
166
}
167
167
}
168
+
168
169
df = pandas .read_gbq (sql , configuration = query_config )
169
170
# [END bigquery_migration_pandas_gbq_query_parameters]
170
171
assert len (df ) > 0
@@ -188,6 +189,7 @@ def test_client_library_upload_from_dataframe(temp_dataset):
188
189
dataset_ref = client .dataset (temp_dataset .dataset_id )
189
190
# [START bigquery_migration_client_library_upload_from_dataframe]
190
191
table_ref = dataset_ref .table ('new_table' )
192
+
191
193
client .load_table_from_dataframe (df , table_ref ).result ()
192
194
# [END bigquery_migration_client_library_upload_from_dataframe]
193
195
client = bigquery .Client ()
@@ -214,6 +216,7 @@ def test_pandas_gbq_upload_from_dataframe(temp_dataset):
214
216
full_table_id = '{}.{}' .format (temp_dataset .dataset_id , table_id )
215
217
project_id = os .environ ['GCLOUD_PROJECT' ]
216
218
# [START bigquery_migration_pandas_gbq_upload_from_dataframe]
219
+
217
220
df .to_gbq (full_table_id , project_id = project_id )
218
221
# [END bigquery_migration_pandas_gbq_upload_from_dataframe]
219
222
client = bigquery .Client ()
0 commit comments