databricks-external-access 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ """Browse Databricks Unity Catalog and fetch tables to local Parquet files."""
2
+
3
+ from importlib.metadata import version
4
+
5
+ from ._workspace import login
6
+ from .browse import Column, Entry, Table, catalogs, describe, overview, schemas, tables
7
+ from .errors import AccessDenied, Error, NotFound, NotSignedIn, UnsupportedTable
8
+ from .fetch import fetch
9
+
10
+ __version__ = version("databricks-external-access")
11
+
12
+ __all__ = [
13
+ "AccessDenied",
14
+ "Column",
15
+ "Entry",
16
+ "Error",
17
+ "NotFound",
18
+ "NotSignedIn",
19
+ "Table",
20
+ "UnsupportedTable",
21
+ "__version__",
22
+ "catalogs",
23
+ "describe",
24
+ "fetch",
25
+ "login",
26
+ "overview",
27
+ "schemas",
28
+ "tables",
29
+ ]
@@ -0,0 +1,100 @@
1
+ """Workspace connection and error translation shared by browsing and fetching."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from collections.abc import Generator
7
+ from contextlib import contextmanager
8
+ from functools import cache
9
+ from pathlib import Path
10
+
11
+ from databricks.sdk import WorkspaceClient
12
+ from databricks.sdk import errors as sdk
13
+ from databricks.sdk.service.catalog import TableInfo
14
+
15
+ from .errors import AccessDenied, Error, NotFound, NotSignedIn
16
+
17
+ # Where `login` remembers the workspace URL.
18
+ SAVED_HOST = "~/.config/databricks-external-access/host"
19
+ # Where the SDK caches the OAuth tokens of the browser sign-in.
20
+ TOKEN_CACHE = "~/.config/databricks-sdk-py/oauth"
21
+
22
+
23
+ def login(host: str) -> None:
24
+ """Remember the workspace (e.g. `https://dbc-1234abcd-5678.cloud.databricks.com`) and sign in.
25
+
26
+ Run once per machine; later sessions reuse the saved workspace. The environment variable
27
+ `DATABRICKS_HOST` overrides it. The workspace is saved only once sign-in has succeeded,
28
+ so a mistyped URL never replaces a working one.
29
+ """
30
+ host = _normalize(host)
31
+ WorkspaceClient(host=host, auth_type="external-browser")
32
+ path = Path(SAVED_HOST).expanduser()
33
+ path.parent.mkdir(parents=True, exist_ok=True)
34
+ path.write_text(host + "\n")
35
+ client.cache_clear()
36
+
37
+
38
+ def _host() -> str:
39
+ saved = Path(SAVED_HOST).expanduser()
40
+ host = os.environ.get("DATABRICKS_HOST") or (saved.read_text() if saved.exists() else "")
41
+ if not host.strip():
42
+ raise Error(
43
+ "No workspace configured. Run databricks_external_access.login("
44
+ "'https://<your-workspace>.cloud.databricks.com') once, or set DATABRICKS_HOST."
45
+ )
46
+ return _normalize(host)
47
+
48
+
49
+ def _normalize(host: str) -> str:
50
+ host = host.strip().rstrip("/")
51
+ if "://" not in host:
52
+ host = f"https://{host}"
53
+ if not host.startswith("https://"):
54
+ raise Error(f"The workspace URL must use https://, got {host!r}.")
55
+ return host
56
+
57
+
58
+ @cache
59
+ def client() -> WorkspaceClient:
60
+ """Sign in to the configured workspace with the SDK's browser OAuth flow.
61
+
62
+ Your identity provider (e.g. Google or Okta SSO) does the authentication. The first
63
+ call opens a browser; the SDK caches and refreshes the token afterwards. This is also
64
+ where a future Databricks Connect session would take its auth from (`client().config`).
65
+ """
66
+ return WorkspaceClient(host=_host(), auth_type="external-browser")
67
+
68
+
69
+ def table_info(name: str) -> TableInfo:
70
+ with explain(f"looking up {name}"):
71
+ return client().tables.get(name)
72
+
73
+
74
+ @contextmanager
75
+ def explain(action: str) -> Generator[None]:
76
+ """Turn the Databricks failures people actually hit into actionable errors."""
77
+ try:
78
+ yield
79
+ except sdk.Unauthenticated as e:
80
+ raise NotSignedIn(
81
+ f"Databricks rejected your sign-in while {action}. Delete the cached tokens in "
82
+ f"{TOKEN_CACHE} and retry; a browser window opens to sign in through your "
83
+ "workspace's SSO."
84
+ ) from e
85
+ except sdk.PermissionDenied as e:
86
+ raise AccessDenied(
87
+ f"Access denied while {action}: {_message(e)} Reading a table from outside "
88
+ "Databricks needs SELECT on the table and EXTERNAL USE SCHEMA on its schema; "
89
+ "ask your Databricks admin for the missing grant."
90
+ ) from e
91
+ except sdk.NotFound as e:
92
+ raise NotFound(
93
+ f"Not found while {action}: {_message(e)} Unity Catalog also reports objects "
94
+ "you cannot see as missing."
95
+ ) from e
96
+
97
+
98
+ def _message(error: Exception) -> str:
99
+ """The server's message without the SDK's appended `Config: host=...` diagnostics."""
100
+ return str(error).split(" Config:")[0]
@@ -0,0 +1,109 @@
1
+ """Discover the catalogs, schemas and tables the signed-in user can see."""
2
+
3
+ from __future__ import annotations
4
+
5
+ # `_workspace` is this package's private module; it is called as an attribute so tests can patch it.
6
+ # pyright: reportPrivateUsage=false
7
+ from concurrent.futures import ThreadPoolExecutor
8
+ from dataclasses import dataclass
9
+
10
+ from databricks.sdk.service.catalog import TableInfo
11
+
12
+ from . import _workspace
13
+ from ._workspace import explain, table_info
14
+ from .errors import Error
15
+
16
+ # Databricks-managed catalogs that `overview()` skips unless asked for by name.
17
+ _MANAGED = {"system", "samples"}
18
+ _COMMENT_WIDTH = 70
19
+
20
+
21
+ @dataclass(frozen=True)
22
+ class Entry:
23
+ """A catalog (`dev`) or schema (`dev.silver`), named by its full dotted name."""
24
+
25
+ name: str
26
+ comment: str | None
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class Column:
31
+ name: str
32
+ type: str
33
+ comment: str | None
34
+
35
+
36
+ @dataclass(frozen=True)
37
+ class Table:
38
+ """A table: full name (`dev.silver.options`), kind (MANAGED, STREAMING_TABLE, ...), columns."""
39
+
40
+ name: str
41
+ kind: str
42
+ comment: str | None
43
+ columns: tuple[Column, ...]
44
+
45
+
46
+ def catalogs() -> list[Entry]:
47
+ """The catalogs you can see."""
48
+ with explain("listing catalogs"):
49
+ return [Entry(str(c.name), c.comment) for c in _workspace.client().catalogs.list()]
50
+
51
+
52
+ def schemas(catalog: str) -> list[Entry]:
53
+ """The schemas of one catalog, named `catalog.schema`."""
54
+ with explain(f"listing schemas in {catalog}"):
55
+ found = _workspace.client().schemas.list(catalog)
56
+ return [Entry(str(s.full_name), s.comment) for s in found]
57
+
58
+
59
+ def tables(schema: str) -> list[Table]:
60
+ """List the tables of a schema given as `catalog.schema`."""
61
+ catalog, _, name = schema.partition(".")
62
+ if not name:
63
+ raise Error(f"Expected a schema as 'catalog.schema', got {schema!r}.")
64
+ with explain(f"listing tables in {schema}"):
65
+ return [_to_table(t) for t in _workspace.client().tables.list(catalog, name)]
66
+
67
+
68
+ def overview(catalog: str | None = None) -> None:
69
+ """Print every catalog, schema and table you can see as a tree.
70
+
71
+ Skips the Databricks-managed `system` and `samples` catalogs and every
72
+ `information_schema` unless you name a catalog explicitly. Lists the schemas in parallel.
73
+ """
74
+ names = [catalog] if catalog else [c.name for c in catalogs() if c.name not in _MANAGED]
75
+ with ThreadPoolExecutor(max_workers=8) as pool:
76
+ schema_names = {
77
+ name: [s.name for s in found if catalog or not s.name.endswith(".information_schema")]
78
+ for name, found in zip(names, pool.map(schemas, names), strict=True)
79
+ }
80
+ every_schema = [s for found in schema_names.values() for s in found]
81
+ listing = dict(zip(every_schema, pool.map(tables, every_schema), strict=True))
82
+ print(_render(schema_names, listing))
83
+
84
+
85
+ def _render(schema_names: dict[str, list[str]], listing: dict[str, list[Table]]) -> str:
86
+ lines: list[str] = []
87
+ for catalog, found_schemas in schema_names.items():
88
+ lines.append(catalog)
89
+ for schema in found_schemas:
90
+ found = listing[schema]
91
+ lines.append(f" {schema.removeprefix(catalog + '.')} ({len(found)} tables)")
92
+ for table in found:
93
+ comment = (table.comment or "").strip().splitlines()[:1]
94
+ short = comment[0][:_COMMENT_WIDTH] if comment else ""
95
+ lines.append(
96
+ f" {table.name.rsplit('.', 1)[-1]:40} {table.kind:18} {short}".rstrip()
97
+ )
98
+ return "\n".join(lines)
99
+
100
+
101
+ def describe(name: str) -> Table:
102
+ """Describe one table given as `catalog.schema.table`."""
103
+ return _to_table(table_info(name))
104
+
105
+
106
+ def _to_table(info: TableInfo) -> Table:
107
+ columns = tuple(Column(str(c.name), str(c.type_text), c.comment) for c in info.columns or [])
108
+ kind = info.table_type.value if info.table_type else "UNKNOWN"
109
+ return Table(str(info.full_name), kind, info.comment, columns)
@@ -0,0 +1,23 @@
1
+ """The errors this package raises. Catch `Error` for any of them, or a subclass for one case."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ class Error(Exception):
7
+ """A failure the caller can act on; the message says how."""
8
+
9
+
10
+ class NotSignedIn(Error):
11
+ """Databricks rejected the sign-in token."""
12
+
13
+
14
+ class AccessDenied(Error):
15
+ """You lack a grant: `SELECT` on the table or `EXTERNAL USE SCHEMA` on its schema."""
16
+
17
+
18
+ class NotFound(Error):
19
+ """The object does not exist, or you cannot see it."""
20
+
21
+
22
+ class UnsupportedTable(Error):
23
+ """The table cannot be read from outside Databricks (kind, format, cloud or pipeline setup)."""
@@ -0,0 +1,196 @@
1
+ """Fetch a table (or a slice of it) to a local Parquet file, without Databricks compute.
2
+
3
+ How it works: Unity Catalog vends short-lived read credentials plus the table's storage
4
+ path (`temporary-table-credentials`); DuckDB's Delta extension reads that path directly and
5
+ writes the result as Parquet, which every dataframe framework can load.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ # `_workspace` is this package's private module; it is called as an attribute so tests can patch it.
11
+ # pyright: reportPrivateUsage=false
12
+ import os
13
+ import sys
14
+ import tempfile
15
+ from collections.abc import Sequence
16
+ from pathlib import Path
17
+
18
+ import duckdb
19
+ from databricks.sdk.errors import BadRequest
20
+ from databricks.sdk.service.catalog import (
21
+ AwsCredentials,
22
+ DataSourceFormat,
23
+ TableInfo,
24
+ TableOperation,
25
+ TableType,
26
+ )
27
+
28
+ from . import _workspace
29
+ from ._workspace import explain, table_info
30
+ from .errors import UnsupportedTable
31
+
32
+ # Unity Catalog can vend credentials only for these; views, foreign and shared
33
+ # (DELTASHARING) tables have no storage path to read. Pipeline tables report no format.
34
+ _READABLE_KINDS = {
35
+ TableType.MANAGED,
36
+ TableType.EXTERNAL,
37
+ TableType.STREAMING_TABLE,
38
+ TableType.MATERIALIZED_VIEW,
39
+ }
40
+ _READABLE_FORMATS = {DataSourceFormat.DELTA, None}
41
+
42
+ # Tables written by pipeline `apply_changes` keep bookkeeping columns in storage; the logical
43
+ # table hides them and drops deleted and expectation-failing rows. Unity Catalog records this
44
+ # as the table's `spark.internal.streaming_table.reconciliation_query`; these are its filters.
45
+ _BOOKKEEPING_FILTERS = {
46
+ "__DeleteVersion": "__DeleteVersion IS NULL",
47
+ "__MEETS_DROP_EXPECTATIONS": "(__MEETS_DROP_EXPECTATIONS IS NULL OR __MEETS_DROP_EXPECTATIONS)",
48
+ }
49
+
50
+
51
+ def fetch(
52
+ name: str,
53
+ *,
54
+ columns: Sequence[str] | None = None,
55
+ where: str | None = None,
56
+ limit: int | None = None,
57
+ dest: Path | str = "data",
58
+ ) -> Path:
59
+ """Write `catalog.schema.table` to `<dest>/<name>.parquet` and return that path.
60
+
61
+ Prints the table's size on storage to stderr before reading any data.
62
+
63
+ Args:
64
+ name: Full table name, `catalog.schema.table`.
65
+ columns: Columns to keep (default: all).
66
+ where: DuckDB SQL predicate selecting rows, e.g. `"ticker = 'NVDA'"`. It runs on your
67
+ machine with your own credentials, so it is not sanitised.
68
+ limit: Maximum number of rows.
69
+ dest: Directory to write into; created if missing.
70
+
71
+ Raises:
72
+ UnsupportedTable: The table cannot be read from outside Databricks.
73
+ AccessDenied: You lack `SELECT` on the table or `EXTERNAL USE SCHEMA` on its schema.
74
+ NotFound: The table does not exist, or you cannot see it.
75
+ NotSignedIn: Databricks rejected your sign-in.
76
+ """
77
+ info = table_info(name)
78
+ _require_readable(info)
79
+ url, aws = _credentials(info)
80
+ full_name = str(info.full_name)
81
+ with _connect(url, aws, _region(full_name)) as con:
82
+ _announce_size(con, full_name, url)
83
+ keep = columns if columns is not None else [str(c.name) for c in info.columns or []]
84
+ query = _select(con, url, keep, where, limit)
85
+ return _write(con, query, url, Path(dest) / f"{full_name}.parquet")
86
+
87
+
88
+ def _require_readable(info: TableInfo) -> None:
89
+ if info.table_type not in _READABLE_KINDS or info.data_source_format not in _READABLE_FORMATS:
90
+ kind = info.table_type.value if info.table_type else "unknown"
91
+ fmt = info.data_source_format.value if info.data_source_format else "none"
92
+ raise UnsupportedTable(
93
+ f"{info.full_name} cannot be fetched: it is a {kind} table in {fmt} format, and only "
94
+ "Delta tables, streaming tables and materialized views can be read from outside "
95
+ "Databricks."
96
+ )
97
+
98
+
99
+ def _credentials(info: TableInfo) -> tuple[str, AwsCredentials]:
100
+ """The table's storage path and short-lived read credentials for it."""
101
+ with explain(f"requesting read credentials for {info.full_name}"):
102
+ try:
103
+ api = _workspace.client().temporary_table_credentials
104
+ vended = api.generate_temporary_table_credentials(
105
+ table_id=info.table_id, operation=TableOperation.READ
106
+ )
107
+ except BadRequest as e:
108
+ raise UnsupportedTable(
109
+ f"{info.full_name} cannot be read from outside Databricks: {e} For pipeline "
110
+ "tables, the owning pipeline must set pipelines.externalMetadata.enabled=true "
111
+ "and run an update."
112
+ ) from e
113
+ if vended.aws_temp_credentials is None or vended.url is None:
114
+ raise UnsupportedTable(
115
+ f"Databricks returned no AWS read credentials for {info.full_name}; only AWS "
116
+ "workspaces are supported."
117
+ )
118
+ return vended.url, vended.aws_temp_credentials
119
+
120
+
121
+ def _region(full_name: str) -> str:
122
+ with explain(f"reading the metastore region for {full_name}"):
123
+ return str(_workspace.client().metastores.summary().region)
124
+
125
+
126
+ def _connect(url: str, aws: AwsCredentials, region: str) -> duckdb.DuckDBPyConnection:
127
+ """An in-memory DuckDB that can read `url` with the given credentials."""
128
+ con = duckdb.connect()
129
+ con.execute("INSTALL delta; LOAD delta; INSTALL httpfs; LOAD httpfs")
130
+ con.execute(
131
+ "CREATE SECRET (TYPE s3, KEY_ID ?, SECRET ?, SESSION_TOKEN ?, REGION ?, SCOPE ?)",
132
+ [aws.access_key_id, aws.secret_access_key, aws.session_token, region, url],
133
+ )
134
+ return con
135
+
136
+
137
+ def _announce_size(con: duckdb.DuckDBPyConnection, full_name: str, url: str) -> None:
138
+ """Tell the user how much the table holds on storage, before any data is read."""
139
+ rows = con.execute("SELECT data_file FROM delta_list_files(?)", [url]).fetchall()
140
+ files = [row[0] for row in rows]
141
+ size = 0
142
+ if files:
143
+ size = int(con.execute("SELECT sum(size) FROM read_blob(?)", [files]).fetchall()[0][0])
144
+ print(
145
+ f"{full_name}: {len(files)} Parquet files, {_human(size)} on storage "
146
+ "(whole table; a slice reads less). Fetching...",
147
+ file=sys.stderr,
148
+ flush=True,
149
+ )
150
+
151
+
152
+ def _select(
153
+ con: duckdb.DuckDBPyConnection,
154
+ url: str,
155
+ columns: Sequence[str],
156
+ where: str | None,
157
+ limit: int | None,
158
+ ) -> str:
159
+ """The query for the logical table: declared columns, bookkeeping rows out, then the slice."""
160
+ rows = con.execute("DESCRIBE SELECT * FROM delta_scan(?)", [url]).fetchall()
161
+ physical = {row[0] for row in rows}
162
+ predicates = [f for col, f in _BOOKKEEPING_FILTERS.items() if col in physical]
163
+ if where:
164
+ predicates.append(f"({where})")
165
+ query = f"SELECT {', '.join(_quote(c) for c in columns)} FROM delta_scan(?)"
166
+ if predicates:
167
+ query += f" WHERE {' AND '.join(predicates)}"
168
+ if limit is not None:
169
+ query += f" LIMIT {int(limit)}"
170
+ return query
171
+
172
+
173
+ def _write(con: duckdb.DuckDBPyConnection, query: str, url: str, target: Path) -> Path:
174
+ """Run `query` into `target` through a unique temporary file, so a failure leaves nothing."""
175
+ target.parent.mkdir(parents=True, exist_ok=True)
176
+ handle, partial = tempfile.mkstemp(dir=target.parent, prefix=f"{target.name}.", suffix=".part")
177
+ os.close(handle)
178
+ try:
179
+ con.execute(f"COPY ({query}) TO ? (FORMAT parquet, COMPRESSION zstd)", [url, partial])
180
+ Path(partial).replace(target)
181
+ finally:
182
+ Path(partial).unlink(missing_ok=True)
183
+ return target
184
+
185
+
186
+ def _quote(identifier: str) -> str:
187
+ return '"' + identifier.replace('"', '""') + '"'
188
+
189
+
190
+ def _human(size: int) -> str:
191
+ value = float(size)
192
+ for unit in ("B", "KiB", "MiB", "GiB"):
193
+ if value < 1024:
194
+ return f"{value:.1f} {unit}"
195
+ value /= 1024
196
+ return f"{value:.1f} TiB"
File without changes
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.5
2
+ Name: databricks-external-access
3
+ Version: 0.1.1
4
+ Summary: Browse Databricks Unity Catalog and fetch tables to local Parquet files, no Databricks compute needed
5
+ Project-URL: Homepage, https://github.com/Northbridge-Capital/databricks-external-access
6
+ Project-URL: Source, https://github.com/Northbridge-Capital/databricks-external-access
7
+ Project-URL: Issues, https://github.com/Northbridge-Capital/databricks-external-access/issues
8
+ Project-URL: Changelog, https://github.com/Northbridge-Capital/databricks-external-access/blob/main/CHANGELOG.md
9
+ Author: Northbridge Capital
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: databricks,delta-lake,duckdb,parquet,unity-catalog
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Database
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Requires-Dist: databricks-sdk>=0.169
25
+ Requires-Dist: duckdb>=2.0
26
+ Description-Content-Type: text/markdown
27
+
28
+ # databricks-external-access
29
+
30
+ [![CI](https://github.com/Northbridge-Capital/databricks-external-access/actions/workflows/ci.yml/badge.svg)](https://github.com/Northbridge-Capital/databricks-external-access/actions/workflows/ci.yml)
31
+
32
+ Browse a Databricks workspace (Unity Catalog) and fetch tables to your own machine as Parquet,
33
+ with no Databricks compute and no secrets. Sign in once through your workspace's SSO.
34
+
35
+ ```python
36
+ import databricks_external_access as dbx
37
+
38
+ dbx.login("https://dbc-1234abcd-5678.cloud.databricks.com") # once per machine
39
+
40
+ dbx.overview() # everything you can see, as a tree
41
+ dbx.describe("main.sales.orders") # columns and descriptions
42
+
43
+ path = dbx.fetch(
44
+ "main.sales.orders",
45
+ columns=["order_date", "customer", "total"],
46
+ where="customer = 'ACME'",
47
+ limit=1_000_000,
48
+ )
49
+ # stderr: main.sales.orders: 2 Parquet files, 51.5 MiB on storage ...
50
+
51
+ import polars as pl # or pandas, DuckDB, Spark, ...
52
+
53
+ df = pl.read_parquet(path)
54
+ ```
55
+
56
+ New here? Open the
57
+ [tutorial notebook](https://github.com/Northbridge-Capital/databricks-external-access/blob/main/notebooks/tutorial.ipynb)
58
+ (`uv run --group notebook jupyter lab`).
59
+
60
+ **Status: alpha (`0.x`).** The API may change between minor versions; see the
61
+ [changelog](https://github.com/Northbridge-Capital/databricks-external-access/blob/main/CHANGELOG.md).
62
+ It is installed from git tags for now; publishing to PyPI is planned.
63
+
64
+ ## Setup
65
+
66
+ 1. Install a pinned release (see the repository's Releases page for the latest tag):
67
+
68
+ ```bash
69
+ uv add "databricks-external-access @ git+https://github.com/Northbridge-Capital/databricks-external-access@v0.1.0"
70
+ # or: pip install "databricks-external-access @ git+https://github.com/Northbridge-Capital/databricks-external-access@v0.1.0"
71
+ ```
72
+
73
+ 2. Run `dbx.login("https://<your-workspace>.cloud.databricks.com")` once. A browser opens to
74
+ sign in through your workspace's SSO; the workspace is remembered and the token is cached and
75
+ refreshed automatically. Scripts and CI can set `DATABRICKS_HOST` instead, which overrides the
76
+ saved workspace.
77
+
78
+ Requires Python 3.11+, an AWS workspace and internet access (DuckDB downloads two extensions on
79
+ first use). To fetch a table you need `SELECT` on it **and** `EXTERNAL USE SCHEMA` on its schema;
80
+ this package never manages grants, so ask your Databricks admin. The full list of requirements
81
+ and constraints is in
82
+ [docs/requirements.md](https://github.com/Northbridge-Capital/databricks-external-access/blob/main/docs/requirements.md).
83
+
84
+ ## API
85
+
86
+ | Function | Returns |
87
+ |---|---|
88
+ | `login("https://...")` | nothing; saves the workspace and signs in (once per machine) |
89
+ | `overview(catalog=None)` | nothing; prints catalogs, schemas and tables as a tree (skips `system`, `samples` and `information_schema` unless you name the catalog) |
90
+ | `catalogs()` | `list[Entry]`: name, comment |
91
+ | `schemas("catalog")` | `list[Entry]`, named `catalog.schema` |
92
+ | `tables("catalog.schema")` | `list[Table]`: name, kind, comment, `columns` (name, type, comment) |
93
+ | `describe("catalog.schema.table")` | one `Table` |
94
+ | `fetch("catalog.schema.table", columns=, where=, limit=, dest="data")` | `Path` to `<dest>/<name>.parquet` |
95
+
96
+ `fetch` prints the table's size on storage to stderr **before** reading any data; for a slice
97
+ this is the whole table, an upper bound. `where` is a DuckDB SQL predicate that runs on your
98
+ machine with your own credentials and is not sanitised. A failed fetch leaves no partial file.
99
+
100
+ ## Errors
101
+
102
+ Everything raises a subclass of `databricks_external_access.Error`, with a message that says what
103
+ to do:
104
+
105
+ | Error | Raised when |
106
+ |---|---|
107
+ | `NotSignedIn` | Databricks rejects your sign-in; delete the token cache and retry |
108
+ | `AccessDenied` | you lack `SELECT` or `EXTERNAL USE SCHEMA` |
109
+ | `UnsupportedTable` | views, shared (Delta Sharing), foreign and non-Delta tables, non-AWS workspaces, and pipeline tables whose pipeline has not enabled `pipelines.externalMetadata.enabled` |
110
+ | `NotFound` | the table does not exist, or you cannot see it |
111
+ | `Error` | anything else actionable, such as no workspace configured or an `http://` URL |
112
+
113
+ ## More
114
+
115
+ - [Requirements](https://github.com/Northbridge-Capital/databricks-external-access/blob/main/docs/requirements.md):
116
+ what it must do, the conditions it works under, what is out of scope, and how each is verified.
117
+ - [Design](https://github.com/Northbridge-Capital/databricks-external-access/blob/main/docs/design.md):
118
+ how it works, why DuckDB, trade-offs, and where to extend it.
119
+ - [Contributing](https://github.com/Northbridge-Capital/databricks-external-access/blob/main/CONTRIBUTING.md):
120
+ setup, checks and the release process.
121
+
122
+ ## License
123
+
124
+ MIT, see
125
+ [LICENSE](https://github.com/Northbridge-Capital/databricks-external-access/blob/main/LICENSE).
@@ -0,0 +1,10 @@
1
+ databricks_external_access/__init__.py,sha256=oSQhpSblHHP672CYh-1LT5NMC5Kbmv7bO-T4AYetAyU,666
2
+ databricks_external_access/_workspace.py,sha256=S0LGPBCYlUTJtoqMpPM4FRq0E-5-hN1f9tv-woLLDTQ,3725
3
+ databricks_external_access/browse.py,sha256=kcdZAvBn4dkYrog_I39GfV6hNjdXJ6nEWroDa6IYv6Y,3951
4
+ databricks_external_access/errors.py,sha256=t_1JOoQ-9maE6Bq-FsDiKeFyEQQDP6oOqBGgdQgAVrs,637
5
+ databricks_external_access/fetch.py,sha256=hogxwNLWhkgwOOXFD1hLXFEmLuxZHT5dgdnhAhQ0lIo,7732
6
+ databricks_external_access/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ databricks_external_access-0.1.1.dist-info/METADATA,sha256=GiC13lffn3ZdSkmoFSXwfK0E1FkK2Ayk9ixSC3t_AOY,6057
8
+ databricks_external_access-0.1.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
9
+ databricks_external_access-0.1.1.dist-info/licenses/LICENSE,sha256=omg-klCAZJHC5HKL1tynLFBkmFb6gsysszTxvhElGXs,1076
10
+ databricks_external_access-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Northbridge Capital
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.