@@ -49,60 +49,12 @@ def _strip_region_tags(sample_text):
4949 return "\n " .join (magic_lines )
5050
5151
52- def test_jupyter_small_query (ipython ):
53- ip = IPython .get_ipython ()
54- ip .extension_manager .load_extension ("google.cloud.bigquery" )
55-
56- # Include a small query to demonstrate that it falls back to the
57- # tabledata.list API when the BQ Storage API cannot be used.
58- sample = """
59- # [START bigquerystorage_jupyter_tutorial_fallback]
60- %%bigquery stackoverflow --use_bqstorage_api
61- SELECT
62- CONCAT(
63- 'https://stackoverflow.com/questions/',
64- CAST(id as STRING)) as url,
65- view_count
66- FROM `bigquery-public-data.stackoverflow.posts_questions`
67- WHERE tags like '%google-bigquery%'
68- ORDER BY view_count DESC
69- LIMIT 10
70- # [END bigquerystorage_jupyter_tutorial_fallback]
71- """
72-
73- result = ip .run_cell (_strip_region_tags (sample ))
74- result .raise_error () # Throws an exception if the cell failed.
75- assert "stackoverflow" in ip .user_ns # verify that variable exists
76-
77-
7852def test_jupyter_tutorial (ipython ):
7953 ip = IPython .get_ipython ()
8054 ip .extension_manager .load_extension ("google.cloud.bigquery" )
8155
8256 # This code sample intentionally queries a lot of data to demonstrate the
8357 # speed-up of using the BigQuery Storage API to download the results.
84- sample = """
85- # [START bigquerystorage_jupyter_tutorial_query]
86- %%bigquery tax_forms --use_bqstorage_api
87- SELECT * FROM `bigquery-public-data.irs_990.irs_990_2012`
88- # [END bigquerystorage_jupyter_tutorial_query]
89- """
90- result = ip .run_cell (_strip_region_tags (sample ))
91- result .raise_error () # Throws an exception if the cell failed.
92-
93- assert "tax_forms" in ip .user_ns # verify that variable exists
94- tax_forms = ip .user_ns ["tax_forms" ]
95-
96- # [START bigquerystorage_jupyter_tutorial_results]
97- tax_forms .head ()
98- # [END bigquerystorage_jupyter_tutorial_results]
99-
100- # [START bigquerystorage_jupyter_tutorial_context]
101- import google .cloud .bigquery .magics
102-
103- google .cloud .bigquery .magics .context .use_bqstorage_api = True
104- # [END bigquerystorage_jupyter_tutorial_context]
105-
10658 sample = """
10759 # [START bigquerystorage_jupyter_tutorial_query_default]
10860 %%bigquery tax_forms
0 commit comments