How to Connect BigQuery to VS Code

Galaxy Glossary

How do I connect Google BigQuery to Visual Studio Code?

Configure Visual Studio Code to query Google BigQuery directly from the editor.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why connect BigQuery to VS Code?

Run, debug, and share queries without leaving your IDE.Gain IntelliSense, version control, and Galaxy-style collaboration in one place.

What do I need first?

Install gcloud, authenticate with gcloud auth login, enable the BigQuery API, and install the VS Code Google Cloud BigQuery extension.

How do I set the connection profile?

Open the Command Palette → BigQuery: Create Connection → choose OAuth or Service Account → enter projectId, optional dataset, and credentials file path if required.

Connection JSON example

{
 "projectId": "acme-store",
 "defaultDataset": "ecommerce",
 "location": "US"
}

How do I run a query?

Create order_analysis.sql, write your SQL, press F1 → BigQuery: Run Query or use the inline ▶ button.

Sample query

SELECT c.name, SUM(oi.quantity * p.price) AS customer_ltv
FROM `acme-store.Orders` o
JOIN `acme-store.Customers` c ON o.customer_id = c.id
JOIN `acme-store.OrderItems` oi ON oi.order_id = o.id
JOIN `acme-store.Products` p ON p.id = oi.product_id
GROUP BY c.name
ORDER BY customer_ltv DESC;

How do I view results?

The extension opens a Results panel with sortable grids.Click the Export icon to save CSV/JSON or copy rows to clipboard.

Can I use version control?

Store .sql files in Git, commit, and push.Galaxy Collections or VS Code Workspaces keep shared queries organized.

What about parameters?

Use @param placeholders in SQL and provide values in the Parameters side panel — similar to Galaxy’s parameterization UX.

Best practices

Keep credentials safe

Reference service-account JSON via environment variables; avoid committing keys.

Enable standard SQL

Add #standardSQL at the top or set workspace setting bigquery.project.defaultDialect to standard.

Reuse datasets

Create workspace settings for default dataset to avoid fully-qualified table names.

Common mistakes

Invalid location errors

Mismatch between dataset location (e.g., EU) and job location (US).Fix by specifying location in connection JSON.

Missing IAM roles

Service account lacks bigquery.dataViewer or bigquery.jobUser. Grant roles in Google Cloud Console.

Need more?

Galaxy’s AI copilot autocompletes, optimizes, and documents BigQuery SQL right inside VS Code.

.

Why How to Connect BigQuery to VS Code is important

How to Connect BigQuery to VS Code Example Usage


-- Find out-of-stock products before today’s promotions
SELECT id, name, stock
FROM `acme-store.Products`
WHERE stock = 0;

How to Connect BigQuery to VS Code Syntax


gcloud auth login
gcloud config set project <PROJECT_ID>

# VS Code settings.json
{
  "bigquery.connections": [
    {
      "projectId": "acme-store",
      "defaultDataset": "ecommerce",
      "keyFilename": "/Users/alex/keys/acme-sa.json",
      "location": "US"
    }
  ]
}

# CLI query example
gcloud bq query --use_legacy_sql=false '
SELECT o.id, total_amount
FROM `acme-store.Orders` o
WHERE DATE(o.order_date) = CURRENT_DATE()'

Common Mistakes

Frequently Asked Questions (FAQs)

Can I connect multiple projects?

Yes. Add multiple objects in bigquery.connections array, each with its own projectId.

Does the extension support parameterized queries?

Yes. Use @param syntax, then supply values in the Parameters panel before execution.

How do I share queries with my team?

Commit .sql files to Git or use Galaxy Collections to endorse and reuse trusted queries.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.