Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
88ba75c
build(deps): Update duckdb requirement from <2,>=1.1 to >=1.1,<3
dependabot[bot] Oct 28, 2026
f5c194f
Merge pull request #111 from eeadata/dependabot/pip/duckdb-gte-1.1-an…
oskaresparza Nov 9, 2026
0bbea9c
Set default Python env manager in VS Code workspace settings
oskaresparza Nov 25, 2026
ddcf388
Put %catalog behind a backend interface and add the backend switch
oskaresparza Nov 30, 2026
9df0cb8
Add the Polaris REST client, the DuckDB engine and the PolarisCatalog…
oskaresparza Nov 30, 2026
498ca8c
Polaris backend: schema, folders, wiki and tags
oskaresparza Nov 30, 2026
35cdd50
Polaris backend: copy, move, views, deletes and versions
oskaresparza Nov 30, 2026
efc272b
Polaris backend: publish through the Document Service
oskaresparza Nov 30, 2026
26dda44
%gpkg on Polaris: read through the Arrow Flight gateway
oskaresparza Nov 30, 2026
e60b294
%dds on Polaris: sign in with Keycloak, namespace paths
oskaresparza Nov 30, 2026
92b5b73
%ingest on Polaris: upload to the object store, then Iceberg or Parquet
oskaresparza Nov 30, 2026
66c4ecc
Document the Polaris backend: README, help texts, .env example
oskaresparza Nov 30, 2026
95c4372
Fix what the live run against the Polaris stack found
oskaresparza Nov 30, 2026
55b8382
Trust the stack's own CA for Polaris, DuckDB and DDS behind its gateway
oskaresparza Nov 30, 2026
4315571
Adapt the %catalog smoke-test notebook to Polaris
oskaresparza Nov 30, 2026
49d5153
%gpkg on Polaris without a Flight gateway: read through the kernel's …
oskaresparza Nov 30, 2026
7006948
Sign in to Keycloak outside JupyterLab with the device-code flow
oskaresparza Nov 30, 2026
26099d3
%ingest as a signed-in user: stage inside the namespace; bucket check
oskaresparza Nov 30, 2026
ec78ece
DuckDB: apply the stack's CA globally, so %gpkg's cursors get it
oskaresparza Nov 30, 2026
a1fa408
Smoke notebook: upload the exported GeoPackage to DDS
oskaresparza Nov 30, 2026
357835d
Take settings and secrets from the JupyterLab pod's environment
oskaresparza Nov 30, 2026
c5dfa67
Test: install DuckDB's httpfs before using its CA settings
oskaresparza Nov 30, 2026
66c58f1
Ignore debugger/lakehouse-ca.crt
oskaresparza Nov 30, 2026
731dc56
%ingest: remove the whole staging folder once the table is loaded
oskaresparza Nov 30, 2026
40079d1
Merge pull request #113 from eeadata/migration_to_polaris
oskaresparza Nov 30, 2026
c13f486
catalog test notebook
oskaresparza Dec 1, 2026
3deabcc
Merge pull request #114 from eeadata/migration_to_polaris
oskaresparza Dec 1, 2026
9519b2b
Catalog test notebook: strip outputs
oskaresparza Dec 1, 2026
c876aad
Merge pull request #115 from eeadata/migration_to_polaris
oskaresparza Dec 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ debugger/bathing_water/
# Windows download metadata (WSL copies it next to downloaded files)
*:Zone.Identifier
debugger/output.gpkg
debugger/lakehouse-ca.crt
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python3"
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python3",
"python-envs.defaultEnvManager": "ms-python.python:system"
}
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,92 @@ limit=..., srid=..., workers=..., progress=print)` returns a `GpkgReport` listin
source, type, SRS and row count. `Catalog.stream_rows(sql, idempotency_key=...)` streams any
SELECT as Arrow batches the same way.

## Polaris backend (the EEA Lakehouse stack)

Dremio is being replaced by [Apache Polaris](https://polaris.apache.org/) — the
Iceberg REST catalog of the EEA Lakehouse stack (`eeadata/EEALakeHouse`,
`local-stack/`). `%catalog`, `%gpkg`, `%dds` and `%ingest` run on either one;
`EEA_CATALOG_BACKEND` picks it (`polaris` or `dremio`; unset: `polaris` when
`POLARIS_URI` is set, else `dremio`, so a Dremio kernel keeps working
unchanged). The commands, their arguments and `%%catalog` stay the same.

**Settings.** In the stack's JupyterLab every setting and secret comes from the
pod's environment — `POLARIS_URI`, `POLARIS_CATALOG`, `POLARIS_VENDED_CREDENTIALS`,
`S3_ENDPOINT`, `DDS_BASE_URL`, `TRINO_CA_FILE`, and your Keycloak token in
`KEYCLOAK_ACCESS_TOKEN` — so nothing needs configuring there, and a `.env` file never
overrides them. Outside it (a laptop, `debugger/`), set them yourself. The names the
JupyterLab kernel receives; in brackets the `local-stack/.env` name read when the first
is not set (see `debugger/.env.example` for all of them):

| Variable | Default | What |
|---|---|---|
| `POLARIS_URI` | `http://localhost:<POLARIS_HOST_PORT>/api/catalog` | Iceberg REST base |
| `POLARIS_CATALOG` [`POLARIS_CATALOG_NAME`] | `eea_lakehouse` | the catalog, and the root of every path |
| `KEYCLOAK_ACCESS_TOKEN` | — | you: Polaris, the Flight gateway and DDS apply your grants |
| `KEYCLOAK_URL`, `KEYCLOAK_CLIENT_ID` | —, `eea-notebook` | outside JupyterLab: the realm to sign in to with `keycloak.login()` (below) |
| `POLARIS_CLIENT_ID` / `_SECRET` [`POLARIS_ROOT_CLIENT_ID` / `_SECRET`] | — | `%catalog` only, when there is no user token |
| `POLARIS_VENDED_CREDENTIALS` | off | per-table storage keys from Polaris |
| `S3_ENDPOINT` [`POLARIS_CATALOG_S3_ENDPOINT_URL` + `_PORT`], `AWS_REGION` | `localhost:9100`, `us-east-1` | the catalog's object store (RustFS) |
| `RUSTFS_ACCESS_KEY` / `_SECRET_KEY` [`POLARIS_CATALOG_S3_ACCESS_KEY_ID` / `_SECRET_ACCESS_KEY`] | — | static storage key (vended credentials off, or no STS) |
| `RUSTFS_ROLE_ARN`, `POLARIS_CATALOG_S3_BUCKET`, `POLARIS_INGEST_S3_PREFIX` | `…/eea-datalakehouse`, namespace's bucket, `_ingestion` | `%ingest`'s own keys and staging area |
| `FLIGHT_HOST` / `FLIGHT_HOST_PORT` | empty / `8815` | Arrow Flight gateway (`%gpkg`); empty: `%gpkg` reads through the kernel's DuckDB |
| `DDS_BASE_URL` | — | Document Service (`%dds`, `publish`) |
| `LAKEHOUSE_CA_FILE` [`TRINO_CA_FILE`] | the system's CAs | CA of the stack's HTTPS gateway (Polaris, DuckDB and DDS behind it) |

**Signing in outside JupyterLab.** Inside the stack's JupyterLab your token is
already in `KEYCLOAK_ACCESS_TOKEN`. Anywhere else, sign in once with the device
login — it prints a link and a code, you sign in in a browser, and the library
keeps that user's token renewed for every call:

```python
from eea_datalakehouse.catalog.keycloak import login
login() # KEYCLOAK_URL, e.g. https://<gateway>/auth/realms/eea_datalakehouse
```

It needs a public client of the realm with the device-code flow and the same
client scopes as `jupyterlab` (`eea-notebook` in EEALakeHouse's realm files).

**What is different on Polaris**

- **Paths** start with the catalog's name instead of `catalog`:
`eea_lakehouse.<domain>.<subdomain>.<area>.draft.stations`. A folder is a
namespace; a table an Iceberg table or a read-only Parquet table; a view an
Iceberg view (its SQL is kept for DuckDB, and for Trino when it reads a table).
- **SQL** runs in the kernel with DuckDB (`iceberg` extension, the catalog
attached as `eea_lakehouse`), as you. Copies cast what Iceberg can't hold
(nanosecond timestamps, unsigned integers, geometry as WKB, …).
- **Wiki and tags** are properties, as the Polaris Navigator keeps them: tags
lower case without `#` (`#public` and `public` are the same tag), and folders
can be tagged too.
- **`publish`** pushes each `#public` view through the Document Service to
`<namespace path>/<view>/` in the public store (you must be a publisher). It
is not all or nothing — an error names the views already published — and
`partition_by` / `overwrite=False` are not available.
- **`%gpkg`** reads the rows through the Arrow Flight gateway (`FLIGHT_HOST`, as
you) — or, with `FLIGHT_HOST` empty, through the kernel's own DuckDB, signed in as
`%catalog` is.
- **`%dds`** signs in with your Keycloak token and stores under the namespace's
path without the catalog name (`eea_lakehouse.water.bwd` → `water/bwd/`).
- **`%ingest`** uploads the files to the catalog's object store — with your
own temporary keys from RustFS STS when available, else the static key (the
commit report says so) — then `table_format` decides the table:

```python
# "iceberg" (default): staged, loaded into an Iceberg table (Parquet, CSV or JSON), staging removed
%ingest ingest(folder="./bw_2026", target_catalog_path="water.bwd.draft", data_format="csv",
csv_options={"delimiter": ";"})
# "parquet": kept as they are, registered as a read-only table; sub_path adds a sub-folder
%ingest ingest(folder="./bw_2026", target_catalog_path="water.bwd.reference", data_format="parquet",
table_format="parquet", table_name="water_temperature", sub_path="2026")
%ingest commit
%ingest promote("eea_lakehouse.water.bwd.reference.water_temperature") # Parquet -> Iceberg, in place
```

`conflict_mode` is `fail`, `append` or `replace`; the target namespace must
exist. `intent`, `upload_mode`, `parallelism`, `multipart` and
`table_definition` belong to the Document Service pipeline and are ignored
(the commit report's notes say so).

## Notebook facade (`%catalog` / `%ingest`)

For interactive use in JupyterLab, `eea_datalakehouse.notebook` registers two line magics
Expand Down Expand Up @@ -597,6 +683,18 @@ context itself — raises `CatalogSessionError` if none is set yet:
| `catalog/rest.py` | `CatalogRestClient` — Dremio's native `/api/v3/catalog` for folders, wiki, and tags (none of which have a SQL/Flight equivalent) |
| `catalog/retry_state.py` | persisted memory of stalled attempts, for `retry_pending()` |
| `catalog/errors.py` | `CatalogOperationError`, `EngineStartingError` |
| `catalog/backend.py` | `CatalogBackend` — the operations `CatalogSession` needs, implemented by `Catalog` (Dremio) and `PolarisCatalog` |
| `catalog/settings.py` | `EEA_CATALOG_BACKEND` and each backend's settings from the environment (kernel names, `local-stack/.env` fallbacks) |
| `catalog/layout.py` | the dataflow folder layout both backends share (`draft`, `versions`, `reference`, `#public`) |
| `catalog/dremio_publish.py` | Dremio's `publish`: `#public` views to the public S3 source, with backups and rollback |
| `catalog/polaris.py` | `PolarisCatalog` — every `%catalog` verb on Polaris |
| `catalog/polaris_rest.py` | `PolarisRestClient` — Iceberg REST (namespaces, tables, views, properties) and Polaris generic tables |
| `catalog/duckdb_engine.py` | `DuckDbEngine` — the kernel's DuckDB with the Polaris catalog attached |
| `catalog/object_store.py` | `ObjectStore` / `s3_credentials` — the catalog's RustFS from the kernel (the user's STS keys, else the static key) |
| `catalog/keycloak.py` | `login()` — device-code sign-in to Keycloak outside JupyterLab; the token is renewed for every client |
| `catalog/dds_public.py` | `PublicDataClient` — the Document Service's public data store, for `publish` on Polaris |
| `geopackage/flight_source.py` | `FlightSource` — `%gpkg` rows from Polaris over the Arrow Flight gateway |
| `dds_ingestion/polaris_ingest.py` | `PolarisIngest` / `promote` — `%ingest` on Polaris: upload, then an Iceberg or a read-only Parquet table |

## Development

Expand Down
47 changes: 47 additions & 0 deletions debugger/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,53 @@ SDI_METADATA_DIR=
DDS_BASE_URL=
DREMIO_BASE_URL=

# --- which catalog %catalog / %gpkg / %dds / %ingest use ----------------------
# polaris or dremio. Empty: polaris when POLARIS_URI is set, else dremio.
EEA_CATALOG_BACKEND=

# --- Polaris (the EEA Lakehouse stack's Iceberg catalog) ----------------------
# Names as the JupyterLab kernel receives them. Each falls back to the name in
# EEALakeHouse's local-stack/.env (in brackets), so that file can be loaded as is.
# Iceberg REST base; without it, http://localhost:<POLARIS_HOST_PORT>/api/catalog.
POLARIS_URI=http://localhost:8181/api/catalog
# The CA of the stack's HTTPS gateway when it has its own (Kubernetes PoC: the
# lakehouse-ca secret; JupyterLab mounts it at /etc/lakehouse-ca/ca.crt
# [TRINO_CA_FILE]). Trusted for Polaris, DuckDB and DDS. Empty: the system's CAs.
LAKEHOUSE_CA_FILE=
# The catalog — also the root of every %catalog path [POLARIS_CATALOG_NAME].
POLARIS_CATALOG=eea_lakehouse
# Who you are: your own Keycloak access token (JupyterHub puts it in the kernel).
# Without it, Polaris client credentials [POLARIS_ROOT_CLIENT_ID / _SECRET] —
# enough for %catalog, not for %gpkg, %dds or publishing, which need a real user.
KEYCLOAK_ACCESS_TOKEN=
# Outside JupyterLab: sign in with eea_datalakehouse.catalog.keycloak.login() (device
# code: a link and a code to open in a browser). The realm's URL, and a public client
# of it with the device-code flow (EEALakeHouse's realm files define eea-notebook).
KEYCLOAK_URL=
KEYCLOAK_CLIENT_ID=eea-notebook
POLARIS_CLIENT_ID=
POLARIS_CLIENT_SECRET=
# true: Polaris hands out per-table storage keys and the static key below is unused.
POLARIS_VENDED_CREDENTIALS=
# The catalog's object store (RustFS), host:port or a URL
# [POLARIS_CATALOG_S3_ENDPOINT_URL + _PORT]; default localhost:<RUSTFS_API_PORT|9100>.
S3_ENDPOINT=
AWS_REGION=us-east-1
# Static key, used when vended credentials are off, and by %ingest when your own
# keys can't be had from RustFS STS [POLARIS_CATALOG_S3_ACCESS_KEY_ID / _SECRET_ACCESS_KEY].
RUSTFS_ACCESS_KEY=
RUSTFS_SECRET_KEY=
# %ingest: the role your own temporary keys are asked for, and where files are
# staged before they become an Iceberg table (bucket: default the target
# namespace's own).
RUSTFS_ROLE_ARN=arn:aws:iam:::role/eea-datalakehouse
POLARIS_CATALOG_S3_BUCKET=
POLARIS_INGEST_S3_PREFIX=_ingestion
# %gpkg reads through the Arrow Flight gateway when FLIGHT_HOST names one; empty:
# through the kernel's own DuckDB, signed in as %catalog is.
FLIGHT_HOST=
FLIGHT_HOST_PORT=8815

# --- SDI catalogue (eea_datalakehouse.sdi) ------------------------------------
# GeoNetwork base URL; the client appends /srv/api/... Empty means the public
# EEA catalogue, https://sdi.eea.europa.eu/catalogue.
Expand Down
1,988 changes: 343 additions & 1,645 deletions debugger/test_catalog_magic.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies = [
"openpyxl>=3.1,<4", # .xlsx reader — handles sparse cells correctly (see bathing_water/README.md)
"xlrd>=2.0,<3", # legacy .xls, some older SDI deliveries
"lxml>=5.2,<7", # ISO 19115-3 metadata records
"duckdb>=1.1,<2", # validate parquet with SQL before it ever leaves the machine
"duckdb>=1.1,<3", # validate parquet with SQL before it ever leaves the machine
# geometry: source encoding in, WKB out (see CLAUDE.md). shapely 2.x only —
# the from_wkt/from_geojson/to_wkb vectorised API the prepare step uses
# does not exist in 1.x. No GDAL/geopandas: reading a GeoPackage or GDB
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pyarrow>=25 # parquet writer + the Arrow types the ingest lane e
openpyxl>=3.1,<4 # .xlsx reader — handles sparse cells correctly (see bathing_water/README.md)
xlrd>=2.0,<3 # legacy .xls, some older SDI deliveries
lxml>=5.2,<7 # ISO 19115-3 metadata records
duckdb>=1.1,<2 # validate parquet with SQL before it ever leaves the machine
duckdb>=1.1,<3 # validate parquet with SQL before it ever leaves the machine

# --- geometry: source encoding in, WKB out (see CLAUDE.md) -----------------
# shapely 2.x only — the from_wkt/from_geojson/to_wkb vectorised API the
Expand Down
7 changes: 7 additions & 0 deletions src/eea_datalakehouse/catalog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from __future__ import annotations

from .backend import CatalogBackend
from .client import Catalog
from .errors import CatalogAuthError, CatalogOperationError, EngineStartingError
from .foldertree import (
Expand Down Expand Up @@ -78,6 +79,7 @@
CatalogSessionError,
CommitReport,
)
from .settings import DremioSettings, PolarisSettings, SettingsError, backend_name
from .sql import (
FLIGHT_LOCATION_ENV_VAR,
TRANSPORT_ENV_VAR,
Expand All @@ -89,6 +91,11 @@
)

__all__ = [
"CatalogBackend",
"DremioSettings",
"PolarisSettings",
"SettingsError",
"backend_name",
"FLIGHT_LOCATION_ENV_VAR",
"TRANSPORT_ENV_VAR",
"Catalog",
Expand Down
Loading