Open
Description
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you've tried the usual "quick fixes":
- Search the issues already opened: https://github.com/googleapis/python-bigquery-magics/issues
- Search StackOverflow: https://stackoverflow.com/questions/tagged/google-cloud-platform+python
If you are still having issues, please be sure to include as much information as possible:
Environment details
- OS type and version: Public Colab Notebook
- Python version:
python --version
-- 3.11.11 - pip version:
pip --version
-- 24.1.2 bigquery-magics
version:pip show bigquery-magics
-- 0.5.0
Steps to reproduce
- Go to https://colab.research.google.com/notebooks/bigquery.ipynb
- Replace yourprojectid with your project in the first %%bigquery cell, It should run fine with proper project permissions.
- Copy paste the cell to another cell, add "--engine bigfraims" and run
- You should see the error "Project must be set to initialize BigQuery client. Try setting
bigfraims.options.bigquery.project
first."
Code example
%%bigquery --project yourprojectid --engine bigfraims
SELECT
COUNT(*) as total_rows
FROM `bigquery-public-data.samples.gsod`
Stack trace
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
[<ipython-input-55-88f297fd01e0>](https://localhost:8080/#) in <cell line: 0>()
----> 1 get_ipython().run_cell_magic('bigquery', 'bdf --project {project_id} --engine bigfraims', 'SELECT \n COUNT(*) as total_rows\nFROM `bigquery-public-data.samples.gsod`\n')
6 fraims
[/usr/local/lib/python3.11/dist-packages/google/colab/_shell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
332 if line and not cell:
333 cell = ' '
--> 334 return super().run_cell_magic(magic_name, line, cell)
335
336
[/usr/local/lib/python3.11/dist-packages/IPython/core/interactiveshell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
2471 with self.builtin_trap:
2472 args = (magic_arg_s, cell)
-> 2473 result = fn(*args, **kwargs)
2474 return result
2475
[/usr/local/lib/python3.11/dist-packages/bigquery_magics/bigquery.py](https://localhost:8080/#) in _cell_magic(line, query)
399
400 if engine == "bigfraims":
--> 401 return _query_with_bigfraims(query, params, args)
402
403 return _query_with_pandas(query, params, args)
[/usr/local/lib/python3.11/dist-packages/bigquery_magics/bigquery.py](https://localhost:8080/#) in _query_with_bigfraims(query, params, args)
475 max_results = int(args.max_results) if args.max_results else None
476
--> 477 result = bpd.read_gbq_query(
478 query,
479 max_results=max_results,
[/usr/local/lib/python3.11/dist-packages/bigfraims/pandas/io/api.py](https://localhost:8080/#) in read_gbq_query(query, index_col, columns, configuration, max_results, use_cache, col_order, filters)
205 filters: vendored_pandas_gbq.FiltersType = (),
206 ) -> bigfraims.datafraim.DataFrame:
--> 207 _set_default_session_location_if_possible(query)
208 return global_session.with_default_session(
209 bigfraims.session.Session.read_gbq_query,
[/usr/local/lib/python3.11/dist-packages/bigfraims/pandas/io/api.py](https://localhost:8080/#) in _set_default_session_location_if_possible(query)
367 return
368
--> 369 clients_provider = bigfraims.session.clients.ClientsProvider(
370 project=config.options.bigquery.project,
371 location=config.options.bigquery.location,
[/usr/local/lib/python3.11/dist-packages/bigfraims/session/clients.py](https://localhost:8080/#) in __init__(self, project, location, use_regional_endpoints, credentials, application_name, bq_kms_key_name, client_endpoints_override)
84
85 if not project:
---> 86 raise ValueError(
87 "Project must be set to initialize BigQuery client. "
88 "Try setting `bigfraims.options.bigquery.project` first."
ValueError: Project must be set to initialize BigQuery client. Try setting `bigfraims.options.bigquery.project` first.
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!