The icelens guide

Reference for everything icelens does. Installing and a first look are in the README; what works on which platform is in Platforms.

Finding your catalog

With nothing configured, icelens offers a demo sandbox, the same at format-version 3, an empty sandbox, any sandbox you made before, or how to connect to your own catalog. Without a terminal it prints one line and exits 1 ("kind": "NoCatalog" under --json).

Settings come from these places, the first that applies winning:

  1. The command line: --uri, --warehouse, and -p key=value for any PyIceberg property (repeatable: -p s3.endpoint=http://localhost:9000).
  2. ICELENS_* environment variables: ICELENS_CATALOG_URI, ICELENS_WAREHOUSE, ICELENS_S3_ENDPOINT, ICELENS_CATALOG_TOKEN, ICELENS_CATALOG_CREDENTIAL.
  3. The profile --catalog NAME names in ~/.pyiceberg.yaml. No .env is read when you name one.
  4. The nearest .env, searching up from the working directory as far as your home directory. Keys match on their suffix, so MYAPP_CATALOG_URI and ACME_S3_ACCESS_KEY work unedited. Only a name ending CATALOG_TOKEN or CATALOG_CREDENTIAL is read as the catalog's secret. A .env that another user owns or can change is refused. --no-env skips the search.
  5. The default profile in ~/.pyiceberg.yaml.
# ~/.pyiceberg.yaml
catalog:
  lab:                                    # icelens --catalog lab
    type: rest
    uri: http://localhost:8181/catalog
    warehouse: analytics
    s3.endpoint: http://localhost:9000
    header.X-Iceberg-Access-Delegation: vended-credentials   # short-lived token per table
  glue:
    type: glue
    warehouse: s3://my-bucket/warehouse   # credentials from the usual AWS chain

icelens --catalogs lists the profiles, and ctrl+o switches between them in the app.

Secrets. Keep them out of the YAML file. Use PyIceberg's environment variables (PYICEBERG_CATALOG__LAB__CREDENTIAL=id:secret) or a .env only you can read. -p token=… works, but a command line is visible to every user on the machine (ps). icelens shows any secret, token, password or credential as ********. The one exception is --serve, which prints the token of the catalog it serves.

Warehouses. A REST catalog that hosts several (Lakekeeper, Polaris) has to be told which one. icelens asks the server for the list: one warehouse is selected for you, several open a picker. icelens --warehouses prints them, and ctrl+w switches in the app.

Keys

↑ ↓ ← →   the tree and the grids         enter    open a table / pin a snapshot
1 … 9 0   jump to a pane                 tab      next pane
/         filter the tree                ctrl+p   fuzzy-find any table
escape    back to the tree               r        reload the selected table (drops the cache)
u         back to the current snapshot   q        quit
, .       older / newer snapshot         [ ]      halve / double the row limit
w         filter rows (SQL WHERE, Data pane)
x         export the focused grid to CSV c        copy the focused cell
l         row lineage on/off (v3, Data)  g        cycle the guide rail
ctrl+r    run the SQL pane, or commit    ?        help
          the Writer pane (sandbox only)
e         the Writer pane (sandbox only)
ctrl+o    switch catalog (~/.pyiceberg.yaml)
ctrl+w    switch warehouse (REST catalogs that host several)

The panes

keypanewhat it shows
1Overviewmetadata.json: format version, uuid, location, refs, properties, recent metadata log entries
2Schemathe viewed snapshot's schema with field ids, nested fields, identifier fields and partition transforms
3Datarows; [ and ] change the limit, w filters, l shows row lineage
4Snapshotsevery commit, oldest first: ◆ current, │ an ancestor of current, ~ off the current chain
5Committhe files one snapshot added and the files it retired
6Manifeststhe snapshot's manifest list, one row per manifest, with partition ranges
7Filesevery live file at that snapshot: data, position deletes, equality deletes
8Partitionspartitions with their file and row counts
9Layoutthe pointer chain: table metadata → snapshot → manifest list → manifests → files
0SQLDuckDB SQL over the catalog; tables are icelens."<namespace>"."<table>"

Time travel

Enter on a snapshot pins it, and every pane re-reads as of that snapshot: its schema, its files, its rows. u returns to the current snapshot.

SQL's own time travel works where DuckDB has attached the catalog (REST, Glue, S3 Tables, and a --v3 sandbox):

SELECT count(*) FROM icelens."demo"."orders" AT (VERSION => <snapshot-id>);

On the other routes DuckDB answers "Catalog type does not support time travel". Use a pane there.

Row lineage, on v3

Format version 3 gives every row a _row_id and a _last_updated_sequence_number that survive file rewrites and compaction. SELECT * does not return them.

The sandbox

A sandbox is a local catalog icelens can write to. It is the only place icelens writes by default.

icelens --sandbox                      # a local catalog; `e` opens the Writer pane
icelens --sandbox teaching             # a named one, kept between runs
icelens --sandbox teaching --sandbox-reset      # empty it
icelens --demo                         # the sandbox called demo, with a table already in it

A sandbox lives in ~/.local/share/icelens/sandboxes/<name>/, readable only by you, or under --sandbox-dir. A path containing # or ? is refused.

The demo table

--demo writes demo.orders with the same five commits on every machine. It needs no network.

commitwhat happenedwhere to look
1120 orders, twelve of them test rows; tagged first-loadOverview's refs
230 late arrivalsManifests: a second manifest
3DELETE the test rows: an overwrite, +108 / -120Commit: one file retired, one added (copy-on-write)
-add channel, rename customer to customer_idSchema: the rename kept field id 4
420 orders with a channelData: channel is null for older rows
-partition by region from here onPartitions, Files: two specs
525 orders, one file per regionLayout

--sandbox NAME puts the demo in another sandbox, and --sandbox-reset starts its history again.

The Writer pane

The Writer pane (e) takes CREATE TABLE t AS SELECT …, INSERT INTO t SELECT … and DELETE FROM t WHERE …, and ctrl+r commits them. Below the editor a ledger lists what each commit did:

 #  statement                                    operation  snapshot id           +rows  -rows  total rows  files
 1  CREATE TABLE demo.sales AS SELECT i AS id…   append     365503770289136103      100      0         100      1
 2  INSERT INTO demo.sales SELECT i, 'r0', 9.99  append     943875501117234734       10      0         110      2
 3  DELETE FROM demo.sales WHERE region = 'r0'   delete     5294193392015656713       0     10         100      1
 4  DELETE FROM demo.sales WHERE region = 'r0'   overwrite  3471267070479190902      75    100          75      1

Rows 3 and 4 are one DELETE that made two commits. A file holding only deleted rows was dropped (a delete). A file holding deleted rows and rows to keep was rewritten without them (an overwrite, which adds the kept rows back). A statement that changes nothing adds no row.

--v3: a sandbox at format-version 3

icelens --sandbox lesson --v3          # deletion vectors, row lineage, UPDATE, MERGE
icelens --demo --v3                    # the demo table at v3, in the sandbox demo-v3

DuckDB's iceberg extension does the writing, so it has to be installed. icelens serves the sandbox's catalog over Iceberg REST inside its own process, on 127.0.0.1 behind a token made for the run, and DuckDB writes through that. Nothing is left listening when icelens exits.

A sandbox made v3 stays v3, also after --sandbox-reset, and keeps the v2 tables it had. A new table is v3 unless the statement says WITH ("format-version" = 2).

The v3 demo:

commitwhat happenedwhere to look
1, 2120 orders, then 30 more; the first tagged first-loadSnapshots: first row id 0, then 120
3DELETE the test rows: a delete, not an overwriteFiles: a deletion vector, and the data file untouched
4UPDATE one orderData, l: order 7 keeps _row_id 6
-ALTER TABLE … ADD COLUMN channelSchema: schema 1
520 orders with a channelData: channel null for older rows
6, 7one MERGE: a correction, then two new ordersSnapshots: one statement, two snapshots

--serve: the sandbox, for other engines

icelens --demo --v3 --serve      # or: --sandbox NAME --serve

Serves the sandbox's catalog over Iceberg REST until ctrl+c, and prints the URI, the warehouse and a bearer token as a ~/.pyiceberg.yaml entry and a DuckDB ATTACH. --json prints one object instead. --port N and ICELENS_SERVE_TOKEN (16 characters or more) fix the port and the token.

--rest: a sandbox in a catalog you run

icelens --sandbox lesson --rest --warehouse lab      # takes the usual connection settings

Puts the sandbox in one namespace, sandbox_lesson, of a catalog you already run (Lakekeeper, Polaris, anything DuckDB attaches). Writes outside that namespace are refused: a bare sales means sandbox_lesson.sales, and crm.accounts is an error. DuckDB does the writing, so UPDATE and MERGE work, and tables are v3 unless you ask for v2.

append     on sandbox_lesson.sales · +100 rows · snapshot 1698712542466490902 · duckdb through the catalog
delete     on sandbox_lesson.sales ·  -25 rows · snapshot 1977770655278908907 · duckdb through the catalog
overwrite  on sandbox_lesson.sales · +25 rows · -25 rows · snapshot 319156682419751923 · duckdb through the catalog

A delete here leaves a deletion vector beside the data file instead of rewriting it. An UPDATE is reported as +25 / -25: a delete and an insert. The ledger's row counts are measured, because the snapshot summary's added-position-deletes overcounts when a deletion vector is rewritten.

How rows are read

The metadata panes work the same on every catalog, through PyIceberg. Rows come by one of three routes, and the status bar names the one in use:

routewhenhow
attachedREST, Glue, S3 TablesDuckDB attaches the catalog and sees new tables and snapshots itself
scanning metadata filesHive, SQL, DynamoDB, in-memory, or a REST catalog DuckDB refusedPyIceberg finds each table's metadata.json and DuckDB scans it
pyiceberg scansDuckDB's iceberg extension is missing, or DuckDB could not reach a table's filesPyIceberg reads the rows

OAuth catalogs: Polaris, Snowflake, Databricks

These log in with OAuth and hand out storage credentials per table, so the connection needs a login and nothing about the store:

# Apache Polaris, and Snowflake Open Catalog (which is Polaris)
icelens --uri https://HOST/api/catalog --warehouse CATALOG \
        -p credential=CLIENT_ID:CLIENT_SECRET -p scope=PRINCIPAL_ROLE:ALL

# Snowflake Horizon: the warehouse is a database, the secret is a PAT, and there is no client id
icelens --uri https://ORG-ACCOUNT.snowflakecomputing.com/polaris/api/catalog --warehouse DATABASE \
        -p credential=$SNOWFLAKE_PAT -p scope=session:role:ROLE

# Databricks Unity Catalog: the warehouse is a Unity catalog; a PAT, or a service principal
icelens --uri https://WORKSPACE/api/2.1/unity-catalog/iceberg-rest --warehouse UC_CATALOG -p token=$DATABRICKS_PAT
icelens --uri https://WORKSPACE/api/2.1/unity-catalog/iceberg-rest --warehouse UC_CATALOG \
        -p credential=SP_ID:SP_SECRET -p oauth2-server-uri=https://WORKSPACE/oidc/v1/token -p scope=all-apis

Google Cloud Storage and BigLake

icelens --uri https://biglake.googleapis.com/iceberg/v1/restcatalog \
        --warehouse bl://projects/PROJECT_ID/catalogs/CATALOG_ID \
        -p token=$(gcloud auth print-access-token) \
        -p header.x-goog-user-project=PROJECT_ID

Without a terminal

Every pane prints, as a table, CSV or JSON:

icelens --list                                   # namespaces and table counts
icelens --list demo                              # the tables in one namespace
icelens --pane snapshots demo.orders             # a pane, as a table
icelens --pane layout demo.orders --snapshot <snapshot-id>
icelens --pane files demo.orders --csv > files.csv
icelens --pane data demo.orders --where "region = 'west'" --json
icelens --sql 'SELECT count(*) FROM icelens."demo"."orders"'
icelens --catalogs                               # every catalog in ~/.pyiceberg.yaml
icelens --catalog lab --list                     # one of them

--csv writes exact values to a file or a pipe. Printed to a terminal, control characters are replaced first, as in all other output.

exit codemeaning
0fine
1the catalog or the query refused
2bad usage, including asking for the app when stdout is not a terminal
130interrupted
141the reader closed the pipe, as head does

--sql

--sql runs one DuckDB statement and only reads.

$ icelens --sql "SELECT 1; DROP TABLE demo.orders" --json
{"schema_version": 1, "error": {"kind": "IcelensError",
 "message": "refusing to run DROP: icelens reads. Pass --allow-writes to mean it."}}

Use it with caution. --sql is DuckDB, and DuckDB can read local files and URLs. The check reads the text of a query; it does not isolate DuckDB from the machine, and a spelling it does not know would get through.

Not checked: the app's SQL pane, a sandbox's --write (which may read a local file: CREATE TABLE demo.t AS SELECT * FROM 'orders.csv'), and anything run with --allow-writes, which also attaches the catalog read-write.

--where filters --pane data only. It is one condition: --where "false; SELECT 1" is refused.

--json

--json prints one object. Its rows keep their types: the grid shows 2.5 KB, the JSON 2549.

$ icelens --demo --pane files demo.orders --json | jq '.rows[0] | {size, rows, seq}'
{ "size": 2549, "rows": 7, "seq": 5 }
keywhat it is
schema_version1. Changes only when a key is removed or renamed, or a value's type changes
kindthe pane name, or namespaces / tables / sql / explain / warehouses / catalogs / written / serve
notethe line a person would see on stderr, including how a pane was truncated
count, rowshow many rows, and the rows
columnson data, sql and partitions: each column's Arrow type
table, snapshot, whereon a pane: what was asked for. snapshot is absent for a table with none

Values:

Failures are JSON on stderr, with stdout empty:

$ icelens --pane overview core.nope --json
{"schema_version": 1, "error": {"kind": "IcelensError", "message": "cannot load core.nope: …"}}

The keys of every kind are fixed by tests/test_json_contract.py.

When something fails

For more, --trace FILE (or ICELENS_TRACE=FILE) records every HTTP request PyIceberg made, every statement icelens ran in DuckDB, and each decision about the route, with timings:

07:10:32.203 icelens.http        11.1 ms  POST http://127.0.0.1:18181/api/catalog/v1/oauth/tokens -> 200
07:10:32.212 icelens.http         8.2 ms  GET http://127.0.0.1:18181/api/catalog/v1/config?warehouse=lake -> 200
07:08:24.160 icelens.duckdb       2.9 ms  ATTACH IF NOT EXISTS 'lake' AS icelens (TYPE ICEBERG, ENDPOINT '…', TOKEN '***')
07:08:24.160 icelens.catalog  route: DuckDB attached the catalog; it reads rows and runs SQL

Secrets are masked, so the file can go in a bug report. It appends, and only you can read it. Requests DuckDB's own extensions make are not in it; CALL enable_logging('HTTP') in the SQL pane shows those.

Platforms lists common errors and what to do.

Limitations

Rendered from docs/GUIDE.md.