The Google Cloud Data Agent Kit IDE extension's unified SQL editor lets you run SQL queries against your Google Cloud data directly from your IDE.
If you're using the Data Agent Kit plugin with a supported coding agent, you can run SQL queries in the agent or use natural language prompts to generate SQL queries.
Supported data sources
Data Agent Kit lets you query tables and views in the following Google Cloud data services:
- BigQuery
- Spanner
- AlloyDB for PostgreSQL
- Cloud SQL for MySQL
- Cloud SQL for PostgreSQL
For Cloud SQL, queries using Identity and Access Management (IAM) database authentication and built-in database authentication (with passwords stored as regional secrets in Secret Manager) are supported. For more information about how Cloud SQL authenticates built-in users with Secret Manager, see Execute SQL statements using the Data API for Cloud SQL for MySQL and Cloud SQL for PostgreSQL. For AlloyDB, only queries using IAM database authentication are supported.
Before you begin
Before querying your data, do the following:
- Install the extension.
- Configure extension settings.
- Review the guidance at Find and explore data.
Create a new SQL file
You can open the SQL editor in multiple ways.
Create a new SQL file from the File menu
- In the VS Code menu bar, click File and then New Text File. An untitled file appears in the editor.
- Save the new file with the
.sqlextension. - Click Select Connection in the editor tab.
- Complete the steps in Configure query settings.
Create a new query from the Catalog
- In the Google Cloud Data Agent Kit tab in the activity bar, expand Catalog to find the dataset that you want to query.
- Right-click or ctrl+click the name of the dataset and then select Query to open a new SQL file preconfigured for that dataset.
Create a new query from the BigQuery section
- In the Google Cloud Data Agent Kit tab in the activity bar, expand BigQuery.
- Click + New Query. An untitled SQL file configured with BigQuery as its data source appears in the editor.
Configure query settings
The settings required for your SQL query vary by Google Cloud service.
AlloyDB
- In the SQL editor, click Open Query Settings.
- Select Databases.
- Select AlloyDB.
- Select a cluster.
- Select an instance. Your query is routed to this instance.
- Select a database.
- Click Save.
BigQuery
- In the SQL editor, click Open Query Settings.
- Select BigQuery.
- Click Save.
Cloud SQL
- In the SQL editor, click Open Query Settings.
- Select Databases.
- Select Cloud SQL.
- Select an instance. Your query is routed to this instance.
- Select a database to query.
Under Authentication method, select how to authenticate:
- IAM database authentication: Authenticate using your Google Cloud account.
Built-in database authentication: Authenticate as a built-in database user whose password is stored as a regional secret in Secret Manager.
- In the User list, select a database user. If the list
can't be loaded, enter the username in the User field.
For Cloud SQL for MySQL, the default
rootuser isn't supported. - In the Password (stored in Secret Manager) list, select the regional secret that stores the user's password. If you don't have a secret yet, select Create new secret in region REGION, enter a Name and the Password, and then click Create Secret. The secret is created in the same region as your instance.
- Optional: In the Secret version list, select a specific version. By default, latest is selected, which always uses the newest version of the secret.
For more information about built-in user and regional secret requirements, see Execute SQL statements using the Data API for Cloud SQL for MySQL and Cloud SQL for PostgreSQL.
- In the User list, select a database user. If the list
can't be loaded, enter the username in the User field.
For Cloud SQL for MySQL, the default
Click Save.
Spanner
- In the SQL editor, click Open Query Settings.
- Select Databases.
- Select Spanner.
- Select an instance. Your query is routed to this instance.
- Select a database to query.
- Click Save.
Change query settings
Query settings are specific to each SQL file. After you open a SQL file, you can change the settings.
- In the editor, click the displayed data source. The Query Settings editor appears.
- Complete the steps in Configure query settings.
Run a query
After you have created a query file and composed your query, click ▷ Run Query.
The Results tab of the Query Results pane shows the query results.
To run a subset of the SQL statements in the query editor, highlight the subset before clicking ▷ Run Query.
SQL editor features
Not all SQL editor features are supported for every data source type. The following table lists the SQL editor features that are supported per data source type during the Preview.
Feature |
BigQuery |
Spanner |
Cloud SQL |
AlloyDB for PostgreSQL |
Query results pane tabs |
||||
Query results |
✅ |
✅ |
✅ |
✅ |
Job information |
✅ |
Not applicable |
Not applicable |
Not applicable |
Execution details |
✅ |
❌ Not supported |
❌ Not supported |
❌ Not supported |
Visualization |
✅ |
✅ |
✅ |
✅ |
SQL editor configuration |
||||
Query settings |
✅ |
✅ |
✅ |
✅ |
Additional features |
||||
Multi-statement query support |
✅ |
✅ |
✅ |
✅ |
Catalog: Insert resource name in editor |
✅ |
✅ |
✅ |
✅ |