Connecting ChatGPT to Your Databricks SQL Warehouse

ChatGPT's website is currently the 5th most visited in the world, according to SimilarWeb. If you're like most people, you're probably using it regularly. But did you know you can connect ChatGPT directly to your Databricks SQL Warehouse and let it query your data?

Note: This feature is currently under active development, so the settings and steps may differ by the time you read this.

ChatGPT connects to Databricks using the Model Context Protocol (MCP).

MCP is a new approach that enables ChatGPT to communicate directly with other tools and databases — for example, to send queries to Databricks or retrieve data from it — without requiring additional plugins or manual setup.

Step 1: Create a connection in Databricks

You'll need to navigate to your Databricks account console to set up the first connection to ChatGPT. This connection will generate a client ID and secret. Note that you'll still need to authenticate from ChatGPT to Databricks using your personal credentials, which enables credential passthrough and applies your access rights to the SQL warehouse and Unity Catalog objects.

Navigate to: Settings > App Connections in the account console

Configure the connection with these settings:

Redirect URL: https://chatgpt.com/connector_platform_oauth_redirect

Access scope: All APIs (Note: I attempted to limit this to just SQL access, but that configuration didn't work)

After configuration, your Client ID and Secret will be displayed:

Step 2: Create a Connection in ChatGPT

Open your ChatGPT settings:

Currently, you need to enable development mode by going to "Apps & Connectors" > "Advanced".

Return to the main settings and click "Create connector"

Add the MCP endpoint as: https:// YOUR_WORKSPACE /api/2.0/mcp/sql

Enter your Client ID and Secret from the previous step.

You can review which actions are available through MCP:

Now authorize the connector to use your personal account:

Step 3: Query Your SQL Data with ChatGPT

In the chat window, you'll now see the Databricks connector available:

Let's ask our first question. Pro tip: I always mention "SQL" and "Databricks" explicitly in my prompts to ensure ChatGPT uses the correct connector:

ChatGPT will request approval to execute the SQL query (this can be a bit tedious—hopefully auto-approval will be available in the future):

You'll see your available schemas:

Let's try another question:

Again, it requests permission. Let's examine the query details this time:

ChatGPT performs the analysis and returns the most popular products without joining the product table. In my experience, Databricks Assistant tends to be smarter for SQL-specific tasks since it's optimized for that use case. However, ChatGPT's advantage is its versatility—you can easily ask it to create a presentation about those popular products or perform other non-SQL tasks.

Conclusion

Connecting ChatGPT to Databricks SQL Warehouse via MCP is a powerful alternative to Databricks Assistant, especially when you need to work with multiple MCP connectors simultaneously. One word of caution: precise prompting is critical. Without clear instructions specifying which connector to use, ChatGPT can easily get confused when multiple connectors are available.

Hubert Dudek

Databricks MVP | Advisor to Databricks Product Board and Technical advisor to SunnyData

https://www.linkedin.com/in/hubertdudek/
Next
Next

SQL: Why Materialized Views Are Your Simplest Data Transformation Tool