# Connect Trino to an Iceberg REST catalog

Configure [Trino](../querying/trino.md) to connect to both the [Iceberg REST catalog](https://iceberg.apache.org/docs/nightly/rest-protocol/) and the underlying object storage. Trino looks up table metadata in the catalog, then reads the data files itself. This setup applies to Apache Polaris, Lakekeeper, Unity Catalog and Cloudflare R2 Data Catalog.

## What you need

| Setting | Example | Where it comes from |
|---|---|---|
| Catalog URI | `https://catalog.example.com/api/catalog` | The catalog's REST endpoint, without the `/v1` path |
| Warehouse | `analytics` | The warehouse name or location your catalog expects |
| Catalog credential | A bearer token, or a client ID and secret | Your catalog's admin console or API |
| Storage key | An S3 access key and secret | Needed when the catalog does not vend credentials |
| Storage endpoint and region | `https://s3.example.com`, `us-east-1` | Your object storage; leave out the endpoint for Amazon S3 |

For querying, a read-only token and a read-only storage key are enough.

## Write the catalog file

A Trino catalog is a properties file in `etc/catalog/`. The file name becomes the catalog name, so `etc/catalog/iceberg.properties` gives you `iceberg.<namespace>.<table>`:

```properties
connector.name=iceberg
iceberg.catalog.type=rest
iceberg.rest-catalog.uri=<catalog_uri>
iceberg.rest-catalog.warehouse=<warehouse>
iceberg.rest-catalog.security=OAUTH2
iceberg.rest-catalog.oauth2.token=<catalog_token>
fs.s3.enabled=true
s3.region=<region>
s3.endpoint=<endpoint>
s3.path-style-access=true
s3.aws-access-key=<access_key_id>
s3.aws-secret-key=<secret_access_key>
```

The `iceberg.*` lines point the [Iceberg connector](https://trino.io/docs/484/connector/iceberg.html#general-configuration) at the catalog; the `fs.*` and `s3.*` lines configure the [S3 file system](https://trino.io/docs/484/object-storage/file-system-s3.html). The [REST catalog properties](https://trino.io/docs/484/object-storage/metastores.html#rest-catalog) you are most likely to need:

| Property | Default | Use |
|---|---|---|
| `iceberg.rest-catalog.uri` | required | The REST endpoint. Trino adds `/v1/...` itself. |
| `iceberg.rest-catalog.warehouse` | none | The warehouse identifier or location, in the form your catalog expects. |
| `iceberg.rest-catalog.prefix` | none | A resource path prefix, if your catalog's documentation gives one. |
| `iceberg.rest-catalog.security` | `NONE` | `NONE`, `OAUTH2`, `SIGV4` or `GOOGLE`. |
| `iceberg.rest-catalog.vended-credentials-enabled` | `false` | Use storage credentials the catalog hands out per table instead of `s3.aws-*`. |
| `iceberg.rest-catalog.nested-namespace-enabled` | `false` | Query tables in nested namespaces. |
| `iceberg.rest-catalog.case-insensitive-name-matching` | `false` | Match namespace and table names regardless of case. |

## Choose the authentication

With `iceberg.rest-catalog.security=OAUTH2`, give Trino either a fixed token or a client credential to exchange for one:

```properties
# A bearer token, sent as-is
iceberg.rest-catalog.oauth2.token=<catalog_token>

# Or a client ID and secret, exchanged for a token
iceberg.rest-catalog.oauth2.credential=<client_id>:<client_secret>
iceberg.rest-catalog.oauth2.scope=<scope>
iceberg.rest-catalog.oauth2.server-uri=<catalog_uri>/v1/oauth/tokens
```

Use one of the two. `oauth2.scope` applies only to the credential flow; use the scope your catalog documents. Set `oauth2.server-uri` to your identity provider's token endpoint when the catalog does not issue tokens itself. Trino refreshes tokens when it knows when they expire (`oauth2.token-refresh-enabled`, on by default).

`SIGV4` signs catalog requests with AWS credentials, which is how Amazon S3 Tables works; the [Trino querying guide](../querying/trino.md#amazon-s3-tables) has a complete S3 Tables catalog file. `GOOGLE` is for BigLake metastore. A catalog without authentication needs `security=NONE`, the default.

## Configure the storage

Trino reads the data files with its own S3 client, using the [S3 file system properties](https://trino.io/docs/484/object-storage/file-system-s3.html#general-configuration):

| Property | Use |
|---|---|
| `fs.s3.enabled` | Turns on Trino's S3 file system. Without it, no `s3.*` property is accepted. |
| `s3.region` | The bucket's region. For S3-compatible storage, use the value your provider documents. |
| `s3.endpoint` | Leave out for Amazon S3. Set it for Cloudflare R2, MinIO, Ceph and other S3-compatible stores. |
| `s3.path-style-access` | `true` sends `https://<endpoint>/<bucket>/<key>` instead of `https://<bucket>.<endpoint>/<key>`. Most self-hosted stores need it. |
| `s3.aws-access-key`, `s3.aws-secret-key` | A static key. Leave both out to use the default AWS credential chain, such as an instance profile. |

Trino 484 calls the switch `fs.s3.enabled`. Older releases call it `fs.native-s3.enabled`; Trino 484 still accepts that name and logs `Configuration property 'fs.native-s3.enabled' has been replaced. Use 'fs.s3.enabled' instead.` at startup.

If your catalog vends credentials, set `iceberg.rest-catalog.vended-credentials-enabled=true` and drop the two `s3.aws-*` lines. Keep `fs.s3.enabled`, `s3.region` and, for S3-compatible storage, `s3.endpoint`.

## Start Trino

Trino's [container image](https://trino.io/docs/484/installation/containers.html) loads every file in `/etc/trino/catalog/`. Mount yours there:

```bash
docker run -d --name trino -p 8080:8080 \
  -v "$PWD/iceberg.properties:/etc/trino/catalog/iceberg.properties:ro" \
  trinodb/trino:484
docker exec -it trino trino
```

The second command opens the [Trino CLI](https://trino.io/docs/484/client/cli.html) inside the container. A catalog file is read at startup only: after you edit it, restart Trino.

## List namespaces and tables

Iceberg namespaces appear as Trino schemas:

```sql
SHOW SCHEMAS FROM iceberg;
```

```text
       Schema
--------------------
 analytics
 information_schema
 system
```

```sql
SHOW TABLES FROM iceberg.analytics;
DESCRIBE iceberg.analytics.events;
```

```text
      Column       |            Type             | Extra | Comment
-------------------+-----------------------------+-------+---------
 signal_type       | varchar                     |       |
 delivery_batch_id | varchar                     |       |
 stream_id         | varchar                     |       |
 ingested_at       | timestamp(6) with time zone |       |
 payload           | varchar                     |       |
```

To list every table in the catalog in one query, use `iceberg.information_schema.tables`.

## Query a table

Tables behave like any other Trino table. The sample table holds events and OpenTelemetry records:

```sql
SELECT signal_type, count(*) AS records
FROM iceberg.analytics.events
GROUP BY signal_type
ORDER BY records DESC;
```

```text
 signal_type | records
-------------+---------
 event       |     300
 span        |      40
 log         |      20
 metric      |      20
```

`payload` is JSON text, so fields inside it come out with Trino's [JSON functions](https://trino.io/docs/484/functions/json.html):

```sql
SELECT json_extract_scalar(payload, '$.data.event') AS event,
       count(*) AS events,
       sum(CAST(json_extract_scalar(payload, '$.data.cents') AS bigint)) / 100.0 AS revenue_usd
FROM iceberg.analytics.events
WHERE signal_type = 'event'
GROUP BY 1
ORDER BY events DESC;
```

```text
   event    | events | revenue_usd
------------+--------+-------------
 page.view  |    177 |        NULL
 order.paid |     53 | 4161.000000
 email.sent |     47 |        NULL
 signup     |     23 |        NULL
```

## Check that writes work

With a token and storage key that can write, Trino creates namespaces and tables in the catalog. Give the namespace a location in a bucket Trino can write to; if your catalog assigns locations itself, leave out `WITH (...)`:

```sql
CREATE SCHEMA iceberg.<namespace> WITH (location = 's3://<bucket>/<path>/');
CREATE TABLE iceberg.<namespace>.trino_check (id integer, note varchar);
INSERT INTO iceberg.<namespace>.trino_check VALUES (1, 'first');
INSERT INTO iceberg.<namespace>.trino_check VALUES (2, 'second');
```

Clean up with `DROP TABLE iceberg.<namespace>.trino_check` and `DROP SCHEMA iceberg.<namespace>`.

## Snapshots and time travel

Every commit to an Iceberg table adds a snapshot. Trino exposes them as [metadata tables](https://trino.io/docs/484/connector/iceberg.html#metadata-tables): append `$snapshots` to the table name and quote the whole name:

```sql
SELECT snapshot_id, operation,
       element_at(summary, 'added-records') AS added_records,
       committed_at
FROM iceberg.<namespace>."trino_check$snapshots"
ORDER BY committed_at;
```

```text
     snapshot_id     | operation | added_records |        committed_at
---------------------+-----------+---------------+-----------------------------
 7647484168615579396 | append    | NULL          | 2026-11-23 00:44:01.140 UTC
 5758468918169947346 | append    | 1             | 2026-11-23 00:44:03.217 UTC
  911080641197171922 | append    | 1             | 2026-11-23 00:44:04.898 UTC
```

`CREATE TABLE` committed an empty snapshot, then each `INSERT` added one. `summary` is a map whose keys vary by operation, so read it with `element_at`, which returns `NULL` for a missing key; `summary['added-records']` fails with `Key not present in map`. `$history`, `$files`, `$manifests`, `$partitions` and `$refs` work the same way.

[Time travel](https://trino.io/docs/484/connector/iceberg.html#time-travel-queries) reads the table as of a snapshot ID, or as of the last snapshot at or before a timestamp:

```sql
SELECT * FROM iceberg.<namespace>.trino_check FOR VERSION AS OF 5758468918169947346;

SELECT * FROM iceberg.<namespace>.trino_check
FOR TIMESTAMP AS OF TIMESTAMP '2026-11-23 00:44:04 UTC';
```

```text
 id | note
----+-------
  1 | first
```

Both return the table before the second insert. `FOR VERSION AS OF` also takes a branch or tag name in quotes. Time travel reaches only snapshots the table still has; snapshot expiry removes older ones.

## Common errors

The CLI prints only the top-level message. Run it as `trino --debug` to see the stack trace with the cause.

| Error | Cause and fix |
|---|---|
| `Cannot obtain metadata` on every query, with `No route for request: GET v1/v1/config` in the stack trace | The URI ends in `/v1`. Trino adds it; remove it from `iceberg.rest-catalog.uri`. Trino still starts, so the error shows only at query time. |
| `Cannot obtain metadata`, with an error from the token route in the stack trace | The credential flow failed: check `oauth2.credential` and `oauth2.server-uri`. |
| `Configuration property 's3.aws-access-key' was not used` | `fs.s3.enabled=true` is missing, so the `s3.*` properties have no file system to apply to. |
| `Error accessing metadata file for table …` caused by `UnknownHostException` for `<bucket>.<host>` | The store needs path-style access: set `s3.path-style-access=true`. Trino retries for minutes before it fails. |
| `Error accessing metadata file for table …` caused by `S3Exception: Forbidden … 403` | The storage key is wrong or cannot read the table's location. |
| `Schema 'analytic' does not exist` | The catalog has no namespace with that name. Check it with `SHOW SCHEMAS`. |
| `No version history table … at or before …` | The timestamp is older than the table's first snapshot. |
| `Pointer value '…' is not in the past` | `FOR TIMESTAMP AS OF` needs a time before now. |
| `Unsupported type for table version: integer` | The snapshot ID was not a `bigint`: copy it from `$snapshots` in full. |

A warning, not an error: with only `oauth2.token` set, the Iceberg client logs that it `is missing the OAuth2 server URI configuration` and falls back to `<catalog_uri>/v1/oauth/tokens`. Queries work; set `iceberg.rest-catalog.oauth2.server-uri` to silence it.

## Where Send2Bucket fits

Send2Bucket is a hosted endpoint for JSON events and OpenTelemetry that appends them to an Iceberg table through your REST catalog, so the catalog file above reads it unchanged. Per [Apache Iceberg destination](../destinations/iceberg-rest.md) and [Delivery format](../delivery-format.md#table-columns):

- You give Send2Bucket the same catalog URI, warehouse, a catalog token and a storage key; it creates the table in a namespace you made. Give Trino its own read-only token and key.
- The columns are `signal_type`, `delivery_batch_id`, `stream_id`, `ingested_at` and `payload`, the record's envelope as JSON text. Fields you sent are under `$.data`.
- Each delivery batch is one append snapshot, so `$snapshots` lists deliveries, and `FOR TIMESTAMP AS OF` shows the table as it was after any delivery whose snapshot has not expired.
- Send2Bucket only appends, so reading while it delivers is safe.

```sql
SELECT snapshot_id, element_at(summary, 'added-records') AS added_records, committed_at
FROM iceberg.<namespace>."<table>$snapshots"
ORDER BY committed_at DESC
LIMIT 5;
```

The [Trino querying guide](../querying/trino.md) has the queries for logs by service and severity and for the slowest spans. To set up the pipeline end to end, see [OpenTelemetry to Apache Iceberg](./opentelemetry-to-iceberg.md).

## Notes

- One catalog file reads one warehouse. For a second catalog or warehouse, add a second file such as `etc/catalog/lake2.properties`.
- Every commit adds metadata and data files, so tables with many small commits slow down over time; compact files and expire snapshots on a schedule, with an engine or service that has write access.
- Your storage provider bills the requests and any egress for the files Trino reads. Filter on a partition or timestamp column where the table has one.
