arrowbricks
Runs SQL against a Databricks SQL warehouse via the Statement Execution API and hands you the result as Arrow -- a Cursor shaped like databricks-sql-python's (execute, fetchone/fetchmany/fetchall, fetchall_arrow/fetchmany_arrow), or stream_query_json for streaming NDJSON. One Arrow engine (arro3), no DuckDB, no pandas/pyarrow.
- Single responsibility: Databricks to Arrow via arro3. No embedded query engine -- that's duckbricks, built on top of this.
- Bring-your-own-auth -- a static token or your own token-refresh callable. No cloud-SDK dependency baked in.
- Result-order preserved even though chunks can complete out of order over the network.
- Chunks are fetched lazily as
fetchone/fetchmany/fetchallactually need them, not all upfront. - Heartbeats between slow chunks (
execute_streamed/stream_query_json), so a caller streaming this over e.g. SSE never goes silent during a cold warehouse start.
Install
pip install arrowbricks
Dependencies: httpx + arro3-core + arro3-io. That's the whole tree.
Quickstart
import asyncio
from arrowbricks import connect
async def main():
conn = connect(
host="adb-1234567890.1.azuredatabricks.net",
warehouse_id="abcd1234efgh5678",
token="dapi...", # or token_provider=... -- see Auth below
)
cursor = conn.cursor()
await cursor.execute("SELECT * FROM my_catalog.my_schema.my_table LIMIT 100")
async for row in cursor:
print(row)
await cursor.execute("SELECT * FROM my_catalog.my_schema.my_table LIMIT 100")
table = await cursor.fetchall_arrow() # an arro3 Table
asyncio.run(main())
For streaming NDJSON (e.g. a FastAPI SSE endpoint, first row out as soon as its chunk arrives):
from arrowbricks import HEARTBEAT, DatabricksClient, stream_query_json
client = DatabricksClient(host=..., warehouse_id=..., token=...)
async for item in stream_query_json(client, "SELECT * FROM my_catalog.my_schema.big_table"):
if item is HEARTBEAT:
continue # forward as an SSE keep-alive comment, e.g.
print(item) # one ready-to-send JSON string per row
See examples/basic.py for a runnable version,
examples/cursor_paging.py for paging a large
result with fetchmany/fetchmany_arrow without buffering it all upfront,
examples/fastapi_sse.py for streaming a query to
a client as Server-Sent Events, or examples/azure_auth.py
for a caching token_provider built on Azure AD (DefaultAzureCredential).
Why not databricks-sql-connector?
The official driver is the right choice if you need full DB-API 2.0 compatibility over Databricks' Thrift/ODBC-style protocol. If you just want a query result as Arrow/JSON in your own async app, it drags in a lot for that: pandas, thrift, openpyxl, pybreaker, pyjwt, oauthlib, lz4, requests, urllib3 as hard dependencies. arrowbricks talks to the plain REST Statement Execution API instead, and its whole dependency tree is httpx + arro3-core + arro3-io. The Cursor API is deliberately shaped like the official driver's so switching between them is mostly a constructor change, but arrowbricks is async throughout (execute, fetchone, etc. are all coroutines) -- there's no sync escape hatch.
Why not duckbricks?
duckbricks does the same Databricks-to-Arrow work, then goes further: it uses a real embedded DuckDB engine to materialize results into your own DuckDB connection/table (feed_select_to_duckdb_table), or push a DuckDB query's result up to Databricks (feed_duckdb_table_to_databricks). If you need that -- a real local SQL engine sitting on top, not just "run this query, get Arrow/JSON back" -- use duckbricks; it depends on arrowbricks for the Databricks/Arrow half. If you don't need DuckDB at all, arrowbricks alone is the smaller, single-responsibility half.
Auth
connect/DatabricksClient take either:
token: str-- a static personal access token or pre-issued OAuth token, ortoken_provider-- a callable (sync or async) returning a token string, called on every request.
arrowbricks has no opinion on how you get a token and no cloud-SDK dependency of its own. If your provider is expensive to call, cache/refresh inside it -- arrowbricks does no caching on your behalf.
conn = connect(host=..., warehouse_id=..., token_provider=my_token_provider)
API
connect(host, warehouse_id, *, token=None, token_provider=None, ...) -> ConnectionConnection.cursor() -> CursorConnection.client -> DatabricksClient-- the same clientcursor()uses, for lower-level access (e.g.stream_query_json,execute_json_statement,upload_volume_file).Cursor.execute(sql, parameters=None, *, row_limit=None, offset=None, catalog=None, schema=None, total_timeout_s=None) -> Cursor-- submits and waits for the statement, like a real DB-API cursor.parameters, if given, is Databricks' own named-parameter format --[{"name": ..., "value": ..., "type": ...}]bound against:namemarkers insql.Cursor.execute_streamed(...)-- same args, but an async generator yieldingHEARTBEATwhile waiting on a slow cold start, then the readyCursor-- for bridging e.g. an SSE connection.Cursor.fetchone() -> tuple | None,Cursor.fetchmany(size) -> list[tuple],Cursor.fetchall() -> list[tuple]Cursor.fetchmany_arrow(size) -> arro3.core.Table,Cursor.fetchall_arrow() -> arro3.core.TableCursoris an async iterator, yielding one row (tuple) at a time.Cursor.description-- DB-API-style[(name, type_name, None, None, None, None, None), ...]afterexecute().stream_query_json(client, sql, **kwargs)-- yieldsHEARTBEAT, then each row as a JSON string, as soon as its chunk arrives. Timestamps come out as full ISO-8601, every column key is always present ("col":nullfor a null value, never an omitted key).DatabricksClient(host, warehouse_id, *, token=None, token_provider=None, ...)-- the lower-level clientConnectionwraps.client.execute_json_statement(sql, ...)for plain JSON rows with no Arrow parse at all;client.upload_volume_file(volume_path, data)/client.delete_volume_file(volume_path)for the Files API.write_ipc_stream(table_or_chunk, buf)-- thin wrapper aroundarro3.io.write_ipc_streamthat always writes uncompressed bodies (see below).
Cursor.execute/execute_streamed/stream_query_json all accept catalog, schema, row_limit, offset, and total_timeout_s.
A note on Arrow IPC compression
write_ipc_stream (and everything in this package that serializes Arrow-IPC bytes) always writes uncompressed bodies. arro3's own default (compression="LZ4") is transparently decompressed by DuckDB's Arrow reader, but not necessarily by every other Arrow IPC reader -- notably, duckdb-wasm's browser-side decoder silently fails to parse LZ4-compressed bodies. If you're producing bytes that might be consumed by something other than a Python DuckDB connection, this default matters.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arrowbricks-0.1.2.tar.gz.
File metadata
- Download URL: arrowbricks-0.1.2.tar.gz
- Upload date:
- Size: 46.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b115322c21a872e76bd0f8bde0aed6e38634e3ed50cb8ab74a0192ecd1bb795
|
|
| MD5 |
1793f370caa4b7e5298019a5cb12d451
|
|
| BLAKE2b-256 |
a6cdca54d53b7b7849998573949fc09bcee0480a1715e64c8881924da74a54b2
|
Provenance
The following attestation bundles were made for arrowbricks-0.1.2.tar.gz:
Publisher:
release.yml on bmsuisse/arrowbricks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arrowbricks-0.1.2.tar.gz -
Subject digest:
8b115322c21a872e76bd0f8bde0aed6e38634e3ed50cb8ab74a0192ecd1bb795 - Sigstore transparency entry: 2310377714
- Sigstore integration time:
-
Permalink:
bmsuisse/arrowbricks@4ff33ca5e5550975e78f904e23330b8c469b91e9 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/bmsuisse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4ff33ca5e5550975e78f904e23330b8c469b91e9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file arrowbricks-0.1.2-py3-none-any.whl.
File metadata
- Download URL: arrowbricks-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba2126fd694e940b4d00554b1daa7e144f57ee94d8beb23e0d5a9e906f178c56
|
|
| MD5 |
ef4fd80cc3632f8576d8e630da7c083e
|
|
| BLAKE2b-256 |
59ea9b9d9f2b063ccbed0b5476db504b47a024b2ecb25e3da45ea3875c0995bb
|
Provenance
The following attestation bundles were made for arrowbricks-0.1.2-py3-none-any.whl:
Publisher:
release.yml on bmsuisse/arrowbricks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arrowbricks-0.1.2-py3-none-any.whl -
Subject digest:
ba2126fd694e940b4d00554b1daa7e144f57ee94d8beb23e0d5a9e906f178c56 - Sigstore transparency entry: 2310377731
- Sigstore integration time:
-
Permalink:
bmsuisse/arrowbricks@4ff33ca5e5550975e78f904e23330b8c469b91e9 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/bmsuisse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4ff33ca5e5550975e78f904e23330b8c469b91e9 -
Trigger Event:
push
-
Statement type: