|
27 | 27 | Parameters: |
28 | 28 |
|
29 | 29 | * ``<destination_var>`` (optional, line argument): |
30 | | - variable to store the query results. |
| 30 | + variable to store the query results. The results are not displayed if |
| 31 | + this parameter is used. |
31 | 32 | * ``--project <project>`` (optional, line argument): |
32 | 33 | Project to use for running the query. Defaults to the context |
33 | 34 | :attr:`~google.cloud.bigquery.magics.Context.project`. |
|
96 | 97 | Query executing: 2.61s |
97 | 98 | Query complete after 2.92s |
98 | 99 |
|
99 | | - Out[3]: name count |
100 | | - ...: ---------------------- |
101 | | - ...: 0 Mary 3736239 |
102 | | - ...: 1 Patricia 1568495 |
103 | | - ...: 2 Elizabeth 1519946 |
104 | | -
|
105 | 100 | In [4]: df |
106 | 101 |
|
107 | 102 | Out[4]: name count |
|
110 | 105 | ...: 1 Patricia 1568495 |
111 | 106 | ...: 2 Elizabeth 1519946 |
112 | 107 |
|
113 | | - In [5]: %%bigquery df --params {"num": 17} |
| 108 | + In [5]: %%bigquery --params {"num": 17} |
114 | 109 | ...: SELECT @num AS num |
115 | 110 |
|
116 | 111 | Out[5]: num |
|
119 | 114 |
|
120 | 115 | In [6]: params = {"num": 17} |
121 | 116 |
|
122 | | - In [7]: %%bigquery df --params $params |
| 117 | + In [7]: %%bigquery --params $params |
123 | 118 | ...: SELECT @num AS num |
124 | 119 |
|
125 | 120 | Out[7]: num |
@@ -262,17 +257,13 @@ def _run_query(client, query, job_config=None): |
262 | 257 | @magic_arguments.argument( |
263 | 258 | "destination_var", |
264 | 259 | nargs="?", |
265 | | - help=( |
266 | | - "If provided, save the output to this variable in addition " "to displaying it." |
267 | | - ), |
| 260 | + help=("If provided, save the output to this variable instead of displaying it."), |
268 | 261 | ) |
269 | 262 | @magic_arguments.argument( |
270 | 263 | "--project", |
271 | 264 | type=str, |
272 | 265 | default=None, |
273 | | - help=( |
274 | | - "Project to use for executing this query. Defaults to the context " "project." |
275 | | - ), |
| 266 | + help=("Project to use for executing this query. Defaults to the context project."), |
276 | 267 | ) |
277 | 268 | @magic_arguments.argument( |
278 | 269 | "--use_legacy_sql", |
@@ -348,4 +339,5 @@ def _cell_magic(line, query): |
348 | 339 | result = query_job.to_dataframe() |
349 | 340 | if args.destination_var: |
350 | 341 | IPython.get_ipython().push({args.destination_var: result}) |
351 | | - return result |
| 342 | + else: |
| 343 | + return result |
0 commit comments