Databricks Connector
A StrataBI Platform Module
Powered by Shaleio
module id databricks_connector · requires StrataBI · one of the data-source connectors
Read-only SQL against a Databricks SQL warehouse (Unity Catalog) for StrataBI tiles. A tile sends one query and its parameters; one Lambda function in your own AWS account, <name_prefix>-databricks_connector-query, runs it through Databricks' SQL Statement Execution API as a service principal (OAuth machine-to-machine), and writes the rows to your own S3 as the tile's result. Values are sent as named parameters, each query has a time budget and is cancelled in Databricks at its deadline, results are typed, and the service principal's secret stays in your Secrets Manager. The connector is available. Live on Databricks Free Edition (2026-12-03): sign-in with the read-only SQL scope, table listing, and queries read through result links. Cancel, timeouts and large results are tested against a local stand-in of the Statement Execution API; Tested lists what has run.
Results come from the workspace's cloud storage, not from the API. Every query asks Databricks for external links: the rows arrive as Arrow files that the function downloads, in parallel, from presigned links on the workspace's own cloud storage. This is the connector's standard path, and it has no native_reader setting. It works on Databricks Free Edition too, which redirects result downloads to a Databricks-hosted address that the connector follows. The function must reach that storage over HTTPS as well as the workspace (The network). The fallback, results = inline, needs only the workspace, but Databricks then returns at most 25 MiB of rows per query.
tile (SQL + inputs) → query Lambda → your Databricks SQL warehouse (service principal, read grants only)
│ ↑
│ └─ Arrow result files, from the workspace's own cloud storage
└→ typed Parquet in your S3 → the tileThis page covers dashboard tiles. Using the connector from StrataLake depends on StrataLake changes that are still in development.
Before installing
1. A SQL warehouse with auto-stop
Use a small warehouse, serverless if the workspace has it (it starts in seconds): size 2X-Small, auto-stop after 5 to 10 minutes (serverless allows 1 minute), and the warehouse's own STATEMENT_TIMEOUT (a SQL configuration parameter, in seconds) set to 900 as a backstop. Copy its HTTP path from Connection details (/sql/1.0/warehouses/<id>).
2. A service principal with read grants only
Create a service principal (in the account console or the workspace settings). Give it the "Databricks SQL access" entitlement and CAN USE on the warehouse, and generate an OAuth secret for it: its client id is the principal's application id. Then grant it read access in Unity Catalog, with your own catalog and schemas:
GRANT USE CATALOG ON CATALOG analytics TO `<application-id>`;
GRANT USE SCHEMA ON SCHEMA analytics.sales TO `<application-id>`;
GRANT SELECT ON SCHEMA analytics.sales TO `<application-id>`;Give it nothing else: no MODIFY, ALL PRIVILEGES, CREATE, MANAGE or ownership, and do not add it to the workspace admins group. Databricks has no read-only session, so these grants are what make the connection read-only. The connector also refuses writes itself (below), but the grants are the control.
3. The sign-in: a secret, or a StrataAPI Manager credential
Each connection signs in with exactly one of the two, never both.
An AWS Secrets Manager secret (secret_arn) with the service principal's OAuth credentials:
{"client_id": "<application id>", "client_secret": "<OAuth secret>"}client_idis the service principal's application id (a UUID), not its numeric id.- The AWS console's own secret type, Databricks Service Principal OAuth Client Secret, works as it is: its
clientIdandclientSecretare read asclient_idandclient_secret. So areClientIDandClientSecretin an "Other type of secret". - The workspace host is the install's
host, or else the secret'shostorworkspaceUrl, with or withouthttps://. - Every value loses the leading and trailing spaces and newlines that a paste into the console brings.
- A personal access token is refused: dashboards should not run as a person.
For each query the connector exchanges the client id and secret for a one-hour token at the workspace's /oidc/v1/token, and keeps neither past that query. Only this connector's function can read the secret. A secret encrypted with a customer-managed KMS key needs secret_kms_key_arn.
A StrataAPI Manager credential (strataapi_credential). In StrataAPI Manager, an administrator adds a credential with provider databricks, scheme basic, as a service account: its username is the client id and its password is the OAuth secret. Bind it to databricks_connector.
- Binding is what grants the read. The function's role may read only credentials bound to
databricks_connector, never another module's. - Revoking or unbinding the credential in StrataAPI Manager stops the next query.
- Another provider's credential is refused.
- A personal credential works, as StrataAPI Manager allows it, but everyone who can see dashboards built on this connector then sees what that person can see in Databricks. Use a service account with only the access these dashboards need.
The OAuth scope (oauth_scope, all-apis by default) is what the token request asks for. Databricks issues a token only for a scope it has assigned the service principal. A principal that Databricks gave only read-only SQL (for example on Databricks Free Edition) needs sql:read:restricted-query. Under that scope the connector cannot open a session, so statements run with the warehouse alone, under the warehouse's own statement timeout and time zone: set the warehouse's STATEMENT_TIMEOUT to 900 s. The connector never switches scopes by itself.
4. The network: HTTPS to the workspace and its storage
| Where the function reaches Databricks from | What to set |
|---|---|
| The internet (the default) | Nothing: the function runs outside a VPC and reaches the workspace and its storage over the internet. |
| A workspace IP access list | subnet_ids and security_group_ids: private subnets behind a NAT gateway with a fixed address. |
| AWS PrivateLink to the workspace | subnet_ids and security_group_ids: the subnets that reach the endpoint. |
The function connects out on port 443 only:
| Host | What for |
|---|---|
The workspace host (dbc-....cloud.databricks.com, adb-....azuredatabricks.net or ....gcp.databricks.com) | The OAuth token, sessions, statements, result links, cancel |
The workspace's cloud storage: on AWS its S3 bucket; on Azure <account>.blob.core.windows.net or .dfs.core.windows.net; on Google Cloud storage.googleapis.com | Result files, through presigned links (not with results = inline) |
s3.<region>.amazonaws.com, secretsmanager.<region>.amazonaws.com, lambda.<region>.amazonaws.com | Results, the secret, StrataBI's status writer |
dynamodb.<region>.amazonaws.com | Only with a StrataAPI Manager credential |
The install's egress output lists these, except the storage host: it belongs to the workspace, and the install cannot name it. Inside a VPC, the subnets need a route to that storage: on AWS a NAT gateway, or an S3 gateway endpoint when the workspace's bucket is in the function's region (its endpoint policy must allow that bucket, and the bucket's policy must not refuse requests from the VPC); for Azure or Google Cloud storage, a NAT gateway. If your network allows outbound traffic only to listed hosts, include the storage host. On Free Edition, result downloads are redirected to a storage host under databricks.com: allow that too. Its full name is not given here, because the connector logs only the end of it. Without the route, the first query fails as unavailable.
A redirected download is followed only over HTTPS, for at most three hops, and only into the workspace's cloud storage or a Databricks domain of that cloud, never with the workspace's sign-in header or cookies. A redirect anywhere else, or too many, fails as unavailable (tested against the local stand-in only). results = inline avoids the storage altogether, up to 25 MiB a result. See also Databricks and BigQuery: where large results come from.
Every call is HTTPS, and only https:// result links are followed. Before it sends the client secret, the connector checks that the host is a Databricks workspace name.
Install
Install StrataBI first: the function uses its AWS SDK for pandas layer to write Parquet.
stratactl install databricks_connectorAnswer the settings with stratactl init module databricks_connector, which saves them in strata.yaml; stratactl install then stores them. Answer the sign-in (secret_arn or strataapi_credential), host and http_path: all three start blank, and an install with no connection stops at its check: "Install at least one connection".
| Setting | Default | |
|---|---|---|
secret_arn or strataapi_credential | One of the two | The secret's ARN, or a StrataAPI Manager credential's name. |
host | Required | The workspace host name, as in https://<host>. |
http_path | Required | The SQL warehouse's HTTP path. The service principal needs CAN USE on the warehouse. |
catalog | The workspace's default | The Unity Catalog catalog the queries run in. Tables are named schema.table in it. |
default_schema | None | The schema an unqualified table name resolves to. Without one, name tables as schema.table. |
results | external_links | Arrow files downloaded in parallel from the workspace's cloud storage, up to the API's 100 GiB. Or inline: JSON rows, cut by the API at 25 MiB, for a function that cannot reach that storage. |
oauth_scope | all-apis | The scope the token asks for. sql:read:restricted-query for a principal Databricks gave only read-only SQL. |
subnet_ids, security_group_ids | None | Only for AWS PrivateLink to the workspace, or an IP access list that admits a NAT gateway's fixed address. The security group allows outbound HTTPS on 443. |
sync_timeout_seconds | 25 | A sync query's budget when the call carries none of its own. A cold warehouse can take longer than 25 s to start: keep tiles async, or the warehouse warm. |
max_query_seconds | 900 | The async timeout: the longest any query runs. You may lower it; see Timing. |
max_rows, max_result_mb | 0, 0 (no limit) | Per result. A positive value cuts the result there, and the result says so. |
memory_mb | 10,240 | The function's memory in MB; the default is Lambda's maximum. A new AWS account may allow only 3,008 MB until AWS raises it: ask AWS Support, or set 3008. |
result_layout | auto | How a large result is written: single, prefix (parts plus a manifest), or auto. A tile's exec.result_layout overrides it. |
allowed_schemas | All the principal can read | |
allowed_catalogs | None | Other catalogs a query may name as catalog.schema.table. Without any, queries stay in the connection's catalog. |
dashboard_tiles, stratalake_access | On, on | |
secret_kms_key_arn | None | The customer-managed KMS key that encrypts the secret. |
To change a setting later, edit strata.yaml and run stratactl update databricks_connector --reconfigure. Tiles use the install's default connection.
From a tile
{"id": "revenue_by_region", "title": "Revenue by region",
"exec": {"type": "lambda", "module_id": "databricks_connector", "lambda_index": 0},
"query": {"sql": ["SELECT region, sum(total) AS revenue FROM sales.orders",
"WHERE ordered_at >= :since GROUP BY region ORDER BY revenue DESC"],
"params": {"since": "since_date"}},
"block": {"type": "table"}}- Placeholders are
:name, mapped to dashboard inputs inquery.params. Each is sent as a typed named parameter, never written into the SQL text. A text value is at most 4,000 characters, and a query at most 100 values. - A list input is refused: one value per placeholder.
- JSON paths (
raw:field) are not placeholders. - A tile runs async by default; add
"sync": truetoexecfor a quick query (Timing). A cold warehouse can take longer than a sync tile's 25 s to start.
What it does in Databricks
Every query goes through these, in order:
- One read-only statement. The SQL is parsed as Databricks SQL. Only a SELECT, or a set operation of them, with or without CTEs, may run: nothing that writes, defines, loads, calls out or runs a command, no table functions, no schema-qualified function calls, and no row locks. This check explains a refusal early; it is not the control.
- Allowed schemas and catalogs, from
allowed_schemasandallowed_catalogs. - Values sent as named parameters.
- The service principal's read grants, which are what make the connection read-only. Databricks has no read-only session.
- Limits: the time budget, and
max_rowsandmax_result_mb.
For each query the connector:
- gets a token from the workspace's
/oidc/v1/token; - opens a session on the warehouse with the catalog and schema, a
STATEMENT_TIMEOUTof the time left plus 1 s,TIMEZONE = UTCandANSI_MODE = true(where the workspace refuses sessions, the warehouse's own timeout applies); - submits the statement with external links and Arrow results, and the values as named parameters. A tile waits in that request for up to 50 s, never past its deadline, so a quick query answers in one round trip;
- polls the statement (every 50 ms, doubling to 1 s) until it ends, downloads the result, and closes the session.
Every call uses version 2.0 of the API (/api/2.0/sql/...). The warehouse's query history shows each statement under the service principal.
Each query writes one audit line to the function's log: who asked (and whether StrataBI verified it), a SHA-256 fingerprint of the SQL, the tables read, how many values, the connection, the outcome and Databricks' error code, rows, bytes and times. Never the SQL text, the values, the rows or a secret.
Why the Statement Execution API. Databricks' Python client, databricks-sql-connector 4.10.0, is 14.3 MiB, or 32.7 MiB with its kernel extra (measured for arm64 and Python 3.13, without pandas, numpy and pyarrow). It fits a connector's package budget, but its default backend is the client's legacy path, it loads pandas when it starts, and it cannot be tested faithfully without a workspace. The REST API is documented request by request. This connector speaks it directly, and its package is 3.4 MiB.
Results
Every statement asks for external links with Arrow results. Databricks answers with a list of chunks; each chunk is an Arrow stream behind a presigned link to the workspace's own cloud storage. The connector reads up to 8 chunks at a time on parallel streams, decoding each as it arrives, with no Python object per value.
- Why always. A statement's result size is not known before it runs. Inline results are cut by the API at 25 MiB, and finding that out would mean running the statement again. External links take results up to 100 GiB, the API's own limit there; a result past it is marked as cut. The cost: a one-row answer also makes one HTTPS request to the cloud storage.
- Order. A statement whose outermost query has
ORDER BYis read as one stream, chunks in order (three downloaded ahead), into one ordered file. WithoutORDER BYthe parts are in no particular order, as SQL allows. - Links. A presigned link is fetched without the Databricks sign-in header. A link within 30 s of its expiry (Databricks issues them for at most 15 minutes) is replaced before use. A link the storage refuses (expired, or a skewed clock) is replaced once; if it is refused again, the run fails as unavailable.
- Row counts. Each chunk's rows are checked against Databricks' count for it: a result is never silently short.
The result is typed Parquet in your deployment's bucket. With result_layout = auto, a result read on parallel streams is written as Parquet parts plus a manifest, and a result read as one stream as one file. A tile that asks for CSV gets one CSV file.
| Databricks | In the result |
|---|---|
| The integer types | 64-bit integer |
FLOAT | 64-bit float |
DECIMAL | Decimal, with the column's declared precision and scale |
TIMESTAMP | Timestamp in UTC |
TIMESTAMP_NTZ | Timestamp, without a time zone |
ARRAY, MAP, STRUCT | JSON text |
| Every other type | Its Arrow type as Databricks sends it, normalised to the result's types |
A value that cannot be converted to its column's type is kept as text. A result cut at max_rows or max_result_mb, or by the API's own limit, is marked as cut, never silently short, and the tile says so.
results = inline keeps the rows in the API's answer as JSON, for a function that cannot reach the workspace's storage. The API then cuts a result at 25 MiB, and the connector marks it as cut.
Timing
- Async, the default: the query may run up to
max_query_seconds(900 s by default), or the tile's deadline if it setsexec.timeout_seconds. - Sync (
"sync": true): 25 s by default, or the tile'sexec.timeout_seconds, at most 120 s. See Execution types. A cold warehouse can take longer than 25 s to start: keep tiles async, or the warehouse warm.
A tenth of the budget (0.5–3 s) is kept back to cancel, write and report. At the deadline the connector cancels the statement in Databricks and closes the downloads in flight, so a blocked read ends at once. The session's STATEMENT_TIMEOUT (the time left plus 1 s) is a backstop on the server, and so is the warehouse's own STATEMENT_TIMEOUT. The tile then says, for example:
The query did not finish within its 25 s budget and was cancelled. Narrow it (filters, fewer columns or rows) or run it as a background tile.
Lambda now allows a function up to 1,800 s, but the install accepts at most 900 s for now: the OpenTofu AWS provider still refuses a longer Lambda timeout. Past 15 minutes, a workload needs S3 caching or a module's own async logic (see Data-source connectors).
One attempt per query
Lambda never retries a connector query: automatic retries are off for the function, and that is not a setting. A query runs once, and a late status from an old attempt cannot overwrite a newer run's.
- If Lambda stops the function itself during an async query (at its 15-minute limit, out of memory, or failing to start), StrataBI's status writer closes the tile as
TIMEOUTorFAILED, unless the tile has been run again since. The function's role may invoke the status writer and no other function. - An async query that waits in Lambda's queue for more than 15 minutes is dropped and reported to StrataBI's status writer, which closes the tile.
Errors
The tile shows a fixed sentence for each kind of failure. Databricks' own error text never leaves the function; the audit line keeps its error code.
| Kind | What the tile says |
|---|---|
| Invalid | The database could not run the query as written. Check the SQL and its parameters. |
| Refused | Only one read-only query (a SELECT) can run through this connector. (Followed by the check that failed, when it adds something.) |
| Parameters | A query parameter is missing or is not a plain value. |
| Credentials | The database did not accept the connector's sign-in. An administrator should check the connection's secret. |
| Denied | The database refused this query for the connector's database user. |
| Not found | The query names a table, view or column the database does not have, or the connector's database user cannot see. |
| Timeout | The query did not finish within its N s budget and was cancelled. Narrow it (filters, fewer columns or rows) or run it as a background tile. |
| Unavailable | The database could not be reached. An administrator should check the connection's host, port and the connector's network settings. |
| Throttled | The database is busy (too many connections or queries). Try again shortly. |
| Failed | The database reported an error running the query. |
One exception: when Databricks refuses the token request, the message keeps Databricks' status, error and error_description (never the client id or secret) and says what to change. That is a scope the principal has not been assigned (with the oauth_scope to set), a wrong client id or secret, an unknown scope, a client that may not use client credentials, or a principal that is not in this workspace or has OAuth turned off. The audit line's code is Databricks' error and the status.
Benchmarks
The connector's side only, against the stand-in. Databricks has no second path to compare: these are its standard path's figures.
| Rows | Rows/s | MB/s | Peak memory |
|---|---|---|---|
| 100,000 | 1,018k | 108.7 | 25 MB |
| 1,000,000 | 1,845k | 196.9 | 286 MB |
| 10,000,000 | 1,895k | 202.2 | 460 MB |
Measured on 2026-12-02 on one laptop (x86, 16 hardware threads), against a local stand-in in a second process that serves external links with Arrow results over loopback. The rows are the kit's typical 12-column row, 107 bytes of Arrow data each, read through the module's handler and streamed as Parquet to a stand-in for S3. MB/s is Arrow data per second; peak memory is how much the process's memory grew while it read the result. This is not a warehouse or its cloud storage: a real warehouse, the network to its storage and Lambda's arm64 cores add their own time. The open streams share fixed memory budgets, so peak memory stays bounded as the rows grow.
Tested
Has run against a real workspace, Databricks Free Edition on AWS, on 2026-12-03: the service principal signed in with the read-only SQL scope (sql:read:restricted-query); the connector listed the workspace's tables; and queries run through StrataLake read their results through external links, following each link's redirect to a Databricks-hosted address. A 68-row grouped query matched the same query run with results = inline, and the whole 1,000-row table matched Databricks' own totals, with no NULLs and not marked as cut. Nothing else has run against a real workspace yet.
Has run in tests, through the function's handler against a local stand-in that answers as Databricks' REST reference documents, with SQLite running the SELECTs and a stand-in for S3:
- the stand-in checks the OAuth client-credentials token request, enforces a session's
STATEMENT_TIMEOUT, runs statements through their states, serves inline and external-link results with the API's byte limit, cancels, and answers errors with Databricks' error classes and SQLSTATEs; - its presigned links go to a separate storage server that refuses a sign-in header, an expired link or a bad signature, and can stall a download half way;
- several chunks are read on parallel streams into Parquet parts and a manifest, and an
ORDER BYis read as one ordered stream; - the row and size limits read chunks in order;
- an expired link is replaced before use, and one the storage refuses is replaced once;
- a link's own headers are sent, but never a sign-in header, and only
httpslinks are followed; - a cancel and a deadline during a stalled download: the download ends at once, and no manifest is written;
- the result types, and that no call leaves version 2.0 of the API.
The OpenTofu (the function's role, no retries, the status writer as the failure destination) is tested with OpenTofu's own tests, including IAM decisions that the role cannot read a credential bound to another module.
Has not run yet, because it needs a real workspace:
- a tile query, a cancel, a deadline, a result in several chunks and a refused redirect, against a real workspace; and a regular workspace (not Free Edition) using the
all-apisscope;
- that a session accepts its settings for a service principal on your warehouse type, and that the session's
STATEMENT_TIMEOUTends a statement with the error the connector reads as a timeout; - the exact Arrow types, chunk sizes and batch sizes Databricks sends, the links' lifetime, and whether links carry their own headers (Azure, Google Cloud, customer-managed keys);
- the exact JSON value formats and chunk sizes with
results = inline; - that the function reaches the workspace's storage from where it runs, and which storage host to allow;
- that a cancel stops warehouse work at once;
- Databricks' real errors for a missing table, a missing grant, and a stopped or deleted warehouse;
- TLS against the Lambda image's certificate store, and the package on arm64;
- a StrataAPI Manager credential in AWS.
AWS services
AWS Lambda (the query function), AWS Secrets Manager (the sign-in), Amazon S3 (results, in your deployment's bucket), Amazon CloudWatch Logs (the audit lines), and optionally Amazon VPC (subnets, a security group, a NAT gateway or an S3 gateway endpoint to the workspace's storage, or AWS PrivateLink), AWS KMS (a customer-managed key on the secret) and Amazon DynamoDB (StrataAPI Manager's registry, with a StrataAPI Manager credential).
Related
Data-source connectors · Data-source connector configuration · Execution types · Build a module · Modules
Shaleio