This document describes how to create, edit, and delete context sets for Spanner Graph in Spanner Studio using a context set file. Context set names must be unique within a database.
To learn about context sets for Spanner Graph, see Context sets overview.
Before you begin
Complete the following prerequisites before creating a context set:
Enable required services
Enable the following services for your project:Prepare a Spanner instance
- Make sure that a Spanner instance is available. For more information, see Create an instance.
- Ensure that you create a database in your instance where you will create the tables. For more information, see Create a database on the Spanner instance.
Required roles and permissions
- Add an IAM user or service account to the instance. For more information, see Apply IAM roles.
- Grant the
roles/spanner.databaseReader,roles/serviceusage.serviceUsageConsumer, androles/geminidataanalytics.queryDataUserroles to the IAM user at the project level. For more information, see Add IAM policy binding for a project. - To create, upload, and manage context sets, grant the Dataplex Catalog Editor (
roles/dataplex.catalogEditor) or Dataplex Catalog Admin (roles/dataplex.catalogAdmin) role to the IAM user at the project level. For more information, see Context sets permissions. - Grant roles and permissions to the IAM user at the project-level for the required databases.
To create an example property graph schema and insert sample graph data in your Spanner database, see Set up and query Spanner Graph.
Create a context set
To create a context set, perform the following steps:
In the Google Cloud console, go to the Spanner page.
Select an instance from the list, and then select your Spanner database.
In the navigation menu, click Spanner Studio.
In the Explorer pane, next to Context sets, click View actions.
Click Create context set.
In the Context set name field, enter a unique context set name (for example,
fingraph-assistant). The context set name is case-sensitive and can contain letters, numbers, hyphens, and underscores.Optional: In the Context set description field, add a description for your context set.
Click Create.
Build context sets
After creating a context set, follow the steps in Build context sets using the context engineering agent to create a context set file for your property graph. You can then edit your context set to upload the context set file.
Edit a context set
To edit a context set and upload a context set file, perform the following steps:
In the Google Cloud console, go to the Spanner page.
Select an instance from the list, and then select a database.
In the navigation menu, click Spanner Studio.
In the Explorer pane, next to Context sets, click View actions.
Click Edit context set.
Optional: Edit the Context set description field.
Click Browse in the Upload context set file section, and select your context set JSON file.
Click Save.
Delete a context set
To delete a context set, perform the following steps:
In the Google Cloud console, go to the Spanner page.
Select an instance from the list, and then select a database.
In the navigation menu, click Spanner Studio.
In the Explorer pane, next to Context sets, click View actions.
Click Delete context set.
In the Delete context set confirmation dialog, enter the name of the context set.
Click Confirm to delete the context set.
What's next
- Learn more about context sets.
- Learn how to test QueryData for Spanner Graph.
- Learn how to build context sets using the context engineering agent.