@@ -155,80 +155,6 @@ def test_client_library_query_magic_results_variable(ipython_interactive):
155
155
ip .user_ns .pop (variable_name ) # clean up variable
156
156
157
157
158
- def test_datalab_magic_parameterized_query (ipython_interactive ):
159
- import pandas
160
-
161
- ip = _set_up_ipython ('google.datalab.kernel' )
162
-
163
- sample = """
164
- # [START bigquery_migration_datalab_magic_define_parameterized_query]
165
- %%bq query -n my_query
166
- SELECT word, SUM(word_count) as count
167
- FROM `bigquery-public-data.samples.shakespeare`
168
- WHERE corpus = @corpus_name
169
- GROUP BY word
170
- ORDER BY count ASC
171
- LIMIT @limit
172
- # [END bigquery_migration_datalab_magic_define_parameterized_query]
173
- """
174
- ip .run_cell (_strip_region_tags (sample ))
175
-
176
- sample = """
177
- # [START bigquery_migration_datalab_magic_query_params]
178
- corpus_name = "hamlet"
179
- limit = 10
180
- # [END bigquery_migration_datalab_magic_query_params]
181
- """
182
- ip .run_cell (_strip_region_tags (sample ))
183
-
184
- sample = """
185
- # [START bigquery_migration_datalab_magic_execute_parameterized_query]
186
- %%bq execute -q my_query --to-dataframe
187
- parameters:
188
- - name: corpus_name
189
- type: STRING
190
- value: $corpus_name
191
- - name: limit
192
- type: INTEGER
193
- value: $limit
194
- # [END bigquery_migration_datalab_magic_execute_parameterized_query]
195
- """
196
- ip .run_cell (_strip_region_tags (sample ))
197
- df = ip .user_ns ["_" ] # Retrieves last returned object in notebook session
198
- assert isinstance (df , pandas .DataFrame )
199
- assert len (df ) == 10
200
-
201
-
202
- def test_client_library_magic_parameterized_query (ipython_interactive ):
203
- import pandas
204
-
205
- ip = _set_up_ipython ('google.cloud.bigquery' )
206
-
207
- sample = """
208
- # [START bigquery_migration_client_library_magic_query_params]
209
- params = {"corpus_name": "hamlet", "limit": 10}
210
- # [END bigquery_migration_client_library_magic_query_params]
211
- """
212
- ip .run_cell (_strip_region_tags (sample ))
213
-
214
- sample = """
215
- # [START bigquery_migration_client_library_magic_parameterized_query]
216
- %%bigquery --params $params
217
- SELECT word, SUM(word_count) as count
218
- FROM `bigquery-public-data.samples.shakespeare`
219
- WHERE corpus = @corpus_name
220
- GROUP BY word
221
- ORDER BY count ASC
222
- LIMIT @limit
223
- # [END bigquery_migration_client_library_magic_parameterized_query]
224
- """
225
- ip .run_cell (_strip_region_tags (sample ))
226
-
227
- df = ip .user_ns ["_" ] # Retrieves last returned object in notebook session
228
- assert isinstance (df , pandas .DataFrame )
229
- assert len (df ) == 10
230
-
231
-
232
158
def test_datalab_list_tables_magic (ipython_interactive ):
233
159
ip = _set_up_ipython ('google.datalab.kernel' )
234
160
0 commit comments