Templates in Google Sheets

The Databricks Connector for Google Sheets lets you save a reusable set of imports as a template in Unity Catalog. Create templates from your saved imports, organize them into groups, and import a template's queries into any sheet. By default, all account users can view and import a group's templates. You can give all account users write access or limit read or write access to specific users. A template stores only the query definitions, not the imported data, so each person who uses it runs the queries with their own Unity Catalog permissions.

This page explains how to set up, create, and manage templates. To import data from a template, see Choose an import method.

Set up templates

A workspace admin or a user with the CREATE CATALOG privilege must set up templates in the Databricks Connector for Google Sheets:

  1. In the connector sidebar, click the Saved imports tab, then click the File document icon. Templates icon.

  2. Enter a name for your first template group. Template groups organize related templates.

  3. Choose who can access templates in the group:

    • Give all account users read access is selected by default. Everyone in the account can view and import the group's templates.
    • Give all account users write access isn't selected by default. Select it to let everyone in the account add, update, and delete templates in the group.

    To limit read or write access to specific users, clear that checkbox and enter each user's email address. Press Enter after each address.

  4. Click Setup Templates. This creates a spreadsheet_templates catalog and a gsheet_templates schema in your workspace's metastore. The connector stores each template group as a table in that schema. It grants all account users USE CATALOG on the catalog and USE SCHEMA and CREATE TABLE on the schema, regardless of the access options. It grants SELECT on the group's table to users with read access, and SELECT and MODIFY to users with write access.

Note

Existing template groups aren't migrated or modified. For a setup created with an earlier connector version, make sure account users have USE CATALOG on the spreadsheet_templates catalog and USE SCHEMA and CREATE TABLE on the gsheet_templates schema. To change who can access a template group later, update the privileges on the group's table, spreadsheet_templates.gsheet_templates.<group-name>, in Unity Catalog. See Manage privileges in Unity Catalog.

Create a template group

After templates are set up, users with USE CATALOG on the spreadsheet_templates catalog and USE SCHEMA and CREATE TABLE on the gsheet_templates schema can create template groups. To create a template in a group, users need MODIFY on the group's table.

Template groups organize related templates and control who can access them. By default, all account users have read access. You can give all account users write access or limit read or write access to specific users.

  1. In the Saved imports tab, click the File document icon. Templates icon, then click + New Group.

  2. Enter a group name using letters, numbers, and underscores.

  3. Choose who can access templates in the group:

    • Give all account users read access is selected by default. Everyone in the account can view and import the group's templates.
    • Give all account users write access isn't selected by default. Select it to let everyone in the account add, update, and delete templates in the group.

    To limit read or write access to specific users, clear that checkbox and enter each user's email address. Press Enter after each address.

  4. Click Create group.

Create a template

Create a template from the imports already saved in your workbook:

  1. In the Saved imports tab, click the File document icon. Templates icon, then click + New Template.
  2. Select a template group and enter a name for the template.
  3. Select the saved imports to include.
  4. Click Create Template.

Manage templates

In the Templates view, you can do the following:

  • Expand a template to see the imports it contains.
  • Edit a template to add or remove imports.
  • Delete a template.

Editing and deleting a template require SELECT and MODIFY on the template group's table.

Limitations

  • You can add imports to or remove imports from a template, but you can't edit the saved query text from within a template. Instead, delete and recreate the template.
  • You can't create templates from the Azure Databricks UI or from Azure Databricks saved queries.
  • A template that includes a pivot table grouped by date and was saved with an earlier version of the connector fails to import. To fix this, recreate the template.

Additional resources