Manage context sets in Spanner Studio

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

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, and roles/geminidataanalytics.queryDataUser roles 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:

  1. In the Google Cloud console, go to the Spanner page.

    Go to Spanner

  2. Select an instance from the list, and then select your Spanner database.

  3. In the navigation menu, click Spanner Studio.

  4. In the Explorer pane, next to Context sets, click View actions.

  5. Click Create context set.

  6. 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.

  7. Optional: In the Context set description field, add a description for your context set.

  8. 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:

  1. In the Google Cloud console, go to the Spanner page.

    Go to Spanner

  2. Select an instance from the list, and then select a database.

  3. In the navigation menu, click Spanner Studio.

  4. In the Explorer pane, next to Context sets, click View actions.

  5. Click Edit context set.

  6. Optional: Edit the Context set description field.

  7. Click Browse in the Upload context set file section, and select your context set JSON file.

  8. Click Save.

Delete a context set

To delete a context set, perform the following steps:

  1. In the Google Cloud console, go to the Spanner page.

    Go to Spanner

  2. Select an instance from the list, and then select a database.

  3. In the navigation menu, click Spanner Studio.

  4. In the Explorer pane, next to Context sets, click View actions.

  5. Click Delete context set.

  6. In the Delete context set confirmation dialog, enter the name of the context set.

  7. Click Confirm to delete the context set.

What's next