> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apache Iceberg snapshots

> Publish an exact Iceberg v2 snapshot from object storage.

Mount the Tables app for one table. Bind a narrowly scoped
[object storage receiver](https://docs.bijection.com/integrations/native-s3.md) to the Tables app's `provider`.
The table root is the full object key prefix without its trailing slash.
Grant the credential read access to the metadata, manifest lists, manifests
and data and delete files under that prefix. On S3 this includes
`s3:GetObject` for version resolution and `s3:GetObjectVersion` for ranges.
Use a bucket with versioning enabled.

```ts bijection/lake.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { label, secret } from "@bijectionhq/bijection";
import { s3Bucket } from "@bijectionhq/app-objects";
import tables from "@bijectionhq/app-tables";

export const lake = label();
export const key = secret();
export const bucket = s3Bucket({ bucket: "warehouse-example", region: "us-east-1", prefix: "orders/" }, key, lake);
export const orders = tables({ data: lake, provider: bucket });
```

Place them in your tree: `export default app({ lake, key, bucket, orders })`.

Grant `orders.operator` and call `orders.source.initialize` with:

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{ format: "iceberg", root: "orders", keys: ["1"],
  scope: "https://warehouse-example.s3.us-east-1.amazonaws.com/orders/" }
```

Set the AWS credential as described in the
[S3 guide](https://docs.bijection.com/integrations/native-s3.md#mount-and-bind). Grant `orders.operator`
to authorized operators and reserve capacity for protected rows, task
results and staged Files at the label.

Call `orders.source.request({ revision, position, metadataKey })` using the revision
from `source.health`, the exact decimal snapshot ID as text and the metadata
JSON object key. The metadata must contain the requested snapshot. An Iceberg
snapshot uses its own schema and manifest list. Physical Parquet columns map
by field ID and partition comparisons use the manifest's partition spec
and values. Use one to four stable, non-null integer or text key fields,
written as decimal Iceberg field IDs so a rename leaves the record key intact.
Column additions with a representable initial default or nullable values,
renames, drops, and partition spec changes are supported for top-level
primitive fields. Equality deletes match strictly older data sequences.
Position deletes can also apply at the same sequence. The app supports
Iceberg v2 with Parquet data and delete files and Avro manifest containers.
[Apache Iceberg format specification](https://iceberg.apache.org/spec/).

## Publication and limits

The previous publication remains readable throughout acquisition. Once all
objects and delete evidence are complete, the app commits the new generation,
rows, keyed changes and active pointer together. A removal in the diff
comes from comparing two complete snapshots evaluated with their format's
own delete semantics. The first snapshot supplies inserts. Acquire later
positions in forward order on the same table incarnation. For a separate
historical baseline, use another mount.

Use `orders.snapshots.at({ position })` for a published generation and page
`snapshots.records` and `snapshots.changes` with its key and a `cursor`. The mount retains completed generations.
`source.setPaused` takes the expected revision and retires an in-flight
run if it changes the source state. Failed or expired runs preserve the
current position. An installer can submit a new request at the reported
revision.

A run has 20 minutes and at most 96 object observations. Iceberg reads up to
32 manifests and 32 data and delete files. Inline metadata uses a 48 KiB
input bound. Large Parquet data, delete and checkpoint files use
version-checked 24 KiB ranges for the footer and each row group.
The footer is at most 128 KiB. Each row-group window is at most 768 KiB
and decodes within the guest's page and row bounds. File parts are sealed
and charged to the app's `data` label as they are staged, then retired on
completion, pause or expiry. Parquet supports uncompressed, Snappy and gzip
pages without INT96. Avro supports null, deflate and Snappy codecs.
The app stages up to 512 input rows across data and delete files, then
publishes up to 128 rows, 16 KiB per row and 128 KiB of record payload per
generation. Overflow and unsupported inputs fail the entire acquisition.
The bundled parser artifact must be installed before bundling.

## Load metadata through an Iceberg REST catalog

Give the catalog and the object store separate `secret()` values.
Bind the catalog's reviewed HTTPS origin and exact LoadTable route in your
own tree. The host projects only `metadata-location` into
the result. Configure an exact canonical object `scope` at table initialization
as in the example above.

```ts bijection/catalog.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { mutation, secret, t } from "@bijectionhq/bijection";
import { catalogObjectKey, icebergRestTable } from "@bijectionhq/app-tables";
import { lake, orders } from "./lake";

export const catalogToken = secret();
export const catalog = icebergRestTable("https://catalog.example.com",
  "/v1/lake/namespaces/sales/tables/orders", { kind: "bearer", secret: catalogToken }, lake);
const position = { revision: t.number, position: t.string };

export const located = mutation(
  { under: lake, args: { ...position, result: t.result(catalog.load) } },
  async (ctx, { result, ...args }) => {
    if (!result.ok || !result.value.ok || result.value.body.location === null) return null;
    const metadataKey = catalogObjectKey(result.value.body.location, "orders",
      "https://warehouse-example.s3.us-east-1.amazonaws.com/orders/", false);
    return await ctx.call(orders.source.request,
      { ...args, metadataKey, checkpoint: null, hudiSavepoint: null });
  },
);

export const load = mutation({ allow: [orders.operator], under: lake, args: position }, async (ctx, args) => {
  await ctx.submit(catalog.load, {}, {
    once: ["orders-catalog", args.revision, args.position],
    then: located.with(args),
  });
});
```

Place `catalogToken`, `catalog`, `located` and `load` in your tree beside
`orders`. The object read checks the
bucket, table prefix and provider version independently of the catalog.
Use a principal with direct read access to the underlying object store.
Catalog-vended credentials, remote signing and server-side planning
are outside this mode.
[Iceberg REST API schema](https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.