Skip to main content

Connect to Databricks from Google Sheets

Preview

This feature is in Public Preview.

This page describes how to use the Databricks Connector for Google Sheets to connect to Databricks from Google Sheets. The Databricks add-on queries Databricks data from within Google Sheets, enabling further analysis.

Before you begin

Import Databricks data into Google Sheets

Import data from Databricks into Google Sheets using the Databricks Connector for Google Sheets by connecting to a Databricks workspace and writing or importing queries.

Step 1: Connect to a Databricks Workspace

  1. In Google Sheets, select Extensions > Databricks Connector > Launch sidebar to open the connector.

    Launch Databricks Connector in Google Sheets

  2. In the Login dialog, enter your Databricks workspace URL. To learn how to find your workspace URL, see Get identifiers for workspace objects.

    • Your workspace URL is in the following format: https://<instance-name>.cloud.databricks.com.
  3. Click Sign in.

  4. A dialog prompts you to sign in or shows your login status.

Step 2: Use the Databricks Connector for Google Sheets

The Databricks add-on for Google Sheets runs queries against data that you have access to in Unity Catalog and imports the data into Google Sheets. The connector automatically saves all queries as imports. You can refresh results, reuse existing queries, and track data origins in Google Sheets.

  1. (Optional) In the Data tab, choose a Databricks SQL warehouse by clicking the circle in the top right of the connector sidebar and selecting your preferred Databricks SQL warehouse. The connector starts the chosen SQL warehouse.

    Switch DBSQL warehouse in Google Sheets connector

  2. To write a new SQL query:

    1. In the connector sidebar, for Source, select Create new query.
    2. Databricks recommends entering a name for your query so it is identifiable.
    3. You can browse through catalogs, schemas, and tables.
    4. In Query text, enter your SQL query.
    5. Under Advanced options, choose if you want to save the query results in a new sheet or in the current sheet.
      • If you choose the current sheet, specify which cell to start adding the data in.
  3. To update or create a new query from an existing SQL query:

    1. In the connector sidebar, for Source, select Select query.
    2. In Query, select the query that you want to use.
    3. If needed, edit the query.
  4. (Optional) To add query parameters to your query:

    1. Ensure your query has at least one query parameter, in the format of :parameter_name. For more on query parameters, see Work with query parameters.
    2. Click + Add Parameter.
    3. Enter the parameter in the first box. Make sure the parameter name matches what you entered in the query editor.
    4. Enter the sheet name and cell location of your parameter value in the second box, including the exclamation point after the sheet name.
    5. To add more query parameters, click + Add Parameter again.

    For example, the following query includes the query parameter :trip_distance, which is defined in sheet sheet_1, cell H1.

    Query with query parameters

  5. To run the query:

    • For a new query, click Save & Import to run the query and populate the sheet.
    • For an existing query, click Update & Import. If you want to save the updated query as a new query, click the down arrow next to Update & Import and click Save as New.

    Full example of Databricks connector sidebar

  6. Your sheet is populated with the query results.

    Sheets populated with query results

note

After the data is imported, the query is tied to the sheet. Changing the sheet name breaks the mapping. For information on how to handle name changes, see Limitations.

Manage imported data

To manage the data you import from Databricks:

  1. Select the Imports tab in the connector sidebar.
  2. To refresh an import, click the refresh icon next to the query name.
  3. To see which sheet an import is connected to, click Kebab menu icon. > Go to Sheet next to the query name.
  4. To edit an import, click Kebab menu icon. > Edit next to the query name.
  5. To delete an import, click Kebab menu icon. > Delete next to the query name. This deletes the query, not the data imported into Google Sheets. You must manually delete imported data.

Manage imported Databricks data in Google Sheets

Change Databricks workspace

To change the Databricks workspace you are connected to:

  1. Select Extensions > Databricks Connector > Change workspace.
  2. Enter the new workspace URL and authenticate to the workspace.

Sharing implications

The add-on does not impact your ability to share your Google Sheet. However, the way you share the file impacts the actions that your recipients can take using the add-on.

  • Recipients with the Viewer or Commenter role can't access the add-on.
  • Recipients with the Editor role and equivalent data asset access can use the add-on with their Google account. They can use the connector just like the owner.
  • Recipients with the Editor role and the same access to the underlying resources can refresh the imports if they are logged in to the same Databricks workspace.

Limitations

  • You cannot rename or delete a sheet that is attached to an existing import. If you do, you cannot refresh the import. To fix this, do one of the following:

    • Recreate the sheet with the exact same name.
    • Create a new import by choosing Select a Query as the source, reusing the import, and clicking Save as New.
  • If two queries are mapped to the same or overlapping ranges, the add-on displays the results of the most recently executed query. This overwrites previously imported data.