Use the Google Cloud for Visual Studio Code extension
The Google Cloud Visual Studio Code (VS Code) extension lets you do the following in VS Code:
- Develop and execute BigQuery notebooks.
- Browse, inspect, and preview BigQuery datasets.
Before you begin
In your local terminal, check to make sure you have Python 3.11 or later installed on your system:
python3 --version
In your local terminal, initialize the gcloud CLI:
gcloud init
Configure a default project:
gcloud config set project PROJECT_ID
Replace
PROJECT_ID
with your default project.Set up Application Default Credentials:
gcloud auth application-default login
Open VS Code, and then in the activity bar, click Extensions.
Using the search bar, find the Jupyter extension, and then click Install. The BigQuery features in VS Code require the Jupyter extension by Microsoft as a dependency.
Install the Google Cloud extension
- Open VS Code, and then in the activity bar, click Extensions.
Using the search bar, find the Google Cloud Code extension, and then click Install.
If prompted, restart VS Code.
The Google Cloud Code icon is now visible in the activity bar.
Configure the extension
- Open VS Code, and then in the activity bar, click Google Cloud Code.
- Open the BigQuery Notebooks section.
- Click Login to Google Cloud. You are redirected to sign in with your credentials.
- Use the top-level application taskbar to navigate to Code > Settings > Settings > Extensions.
- Find Google Cloud Code, and click the Manage icon to open the menu.
- Select Settings.
- For the Cloud Code: Project setting, enter the name of the Google Cloud project that you want to use to execute notebooks and display BigQuery datasets.
- For the Cloud Code > Beta: BigQuery Region setting, enter a BigQuery location. The extension displays datasets from this location.
Develop BigQuery notebooks
- Open VS Code, and then in the activity bar, click Google Cloud Code.
- Open the BigQuery Notebooks section, and click BigQuery Notebook. A
new
.ipynb
file containing sample code is created and opened in the editor. In the new notebook, click Select Kernel, and select a Python kernel. BigQuery notebooks require a local Python kernel for execution. You can create a new virtual environment or use one of the existing ones.
If it hasn't already been installed in your virtual environment, install the
bigframes
client library:- Open the Terminal window.
- Run the
pip install bigframes
command.
You can now write and execute code in your BigQuery notebook.
Explore and preview BigQuery datasets
- Open VS Code, and then in the activity bar, click Google Cloud Code.
- To see datasets and tables from your specified project and region, open the BigQuery Datasets section. BigQuery public datasets are also visible.
- To open a new tab in the editor, click any table name. This tab contains the table details, schema, and preview.
Pricing
The Visual Studio Code extension is free, but you are charged for any Google Cloud services (BigQuery, Dataproc, Cloud Storage) that you use.
What's next
- Learn more about notebooks in BigQuery.
- Learn more about BigQuery DataFrames.