Warehouse exports
A warehouse export writes chosen tables to an Amazon S3 bucket you own, or to storage hosted for you, as Parquet files, on a schedule. The first run writes a full snapshot of each table; every run after that writes only the records created, changed or deleted since, plus every stage move. Snowflake, DuckDB, BigQuery, Redshift and Databricks all read the files directly, so a data team keeps a copy of the workspace next to the rest of its data and models it with the tools it already uses.
If you only remember one thing: the files are a change log, not a mirror. A record appears once per version. To get the current state, keep the newest row per record and drop records whose newest row is a delete — the dbt macros below do exactly that.
Who can do what
Section titled “Who can do what”- Switch exports on for an organization — an organization owner or admin,
in Organization Settings → General → Warehouse export
(
warehouseExportEnabledonPUT /organizations/{organizationId}/features). Off by default. The organization’s plan must include warehouse exports. - Create, change and delete exports — requires
exports:manage, granted to workspace admins only. An export sends every record and field of its tables, whoever can see them in the app, so creating one is the act of deciding that data may leave the workspace.
The plan sets two limits, which the Warehouse exports tab shows: the shortest interval between runs, and how many exports one workspace may have. It also decides whether hosted storage is offered.
Setting up an export
Section titled “Setting up an export”These steps write to a bucket of your own. To have the files hosted for you instead, see Hosted storage.
1. Create an IAM role in your AWS account
Section titled “1. Create an IAM role in your AWS account”The export writes by assuming a role in your account. Create one with any
name (for example tessule-export); you give it its policies in step 3, once
the export exists and has its external id.
2. Add the export
Section titled “2. Add the export”In Workspace Settings → Warehouse exports, choose Add an export and fill in:
| Setting | What it is |
|---|---|
| Name | Your label for the export. |
| Bucket, prefix, region | Where files are written. Every file goes under the prefix (for example tessule/sales/); leave it empty for the bucket’s root. |
| IAM role ARN | The role from step 1. |
| Tables | The tables to send. Each table’s records and their stage history are exported. |
| Leave out | Per table, fields that must not leave the workspace. They are never written. |
| Minutes between runs | At least the plan’s minimum, at most 10080 (a week). |
The destination is fixed once the export exists. To write somewhere else, add another export.
3. Give the role its policies
Section titled “3. Give the role its policies”After you add the export, the app shows the two policies the role needs, ready to copy (and again later from AWS setup on the export’s row):
- Trust policy — lets Tessule’s AWS account assume the role, only when it presents this export’s external id. Another export, even one using the same role, has a different id and cannot assume it.
- Permissions policy — allows
s3:PutObjectunder the export’s prefix and nothing else. The export never reads, lists or deletes objects.
If the bucket has a bucket policy, it must not deny the role. A bucket
encrypted with a customer-managed KMS key also needs the role allowed to use
that key (kms:GenerateDataKey).
The first run starts within five minutes. Until the role is set up, the export shows Failing with the error AWS returned (for example, not authorized to assume the role); it retries on its own once the policies are in place.
Hosted storage
Section titled “Hosted storage”On plans that include it, an export can write to storage hosted for you instead of your own bucket, so the warehouse is the only thing you set up. Each hosted export has its own location and its own IAM reader role, which your warehouse assumes to read that location and nothing else.
-
In Workspace Settings → Warehouse exports, choose Add an export, pick Hosted for you, and choose the tables and interval.
-
The Connect your warehouse dialog opens, showing the export’s location and a Snowflake storage integration that names its reader role:
create storage integration tessule_exporttype = external_stagestorage_provider = 'S3'enabled = truestorage_aws_role_arn = '<the export reader role ARN>'storage_allowed_locations = ('<the export location>');desc integration tessule_export; -
Paste the
STORAGE_AWS_IAM_USER_ARNandSTORAGE_AWS_EXTERNAL_IDthatDESC INTEGRATIONshows into the dialog and save. The reader role then trusts that user, only when it presents that external id. The export’s status moves from Waiting for warehouse to Setting up access while the role is created (usually under a minute), and the first run follows.
An export writes nothing until its warehouse is connected, so no file starts its retention unread. Connect warehouse on the export’s row reopens the dialog to check its status or change the reader.
- Files are kept for 30 days after they are written, then removed. Load them within that time; a warehouse that falls further behind needs a new export, which starts from a full snapshot.
- Deleting a hosted export removes its reader role, so the warehouse loses access within minutes. Its files are removed when their 30 days end.
- The same settings are on the API: create with
"destination": {"kind": "hosted"}, then sendreaderPrincipalArnandreaderExternalIdwithPATCH /warehouse-exports/{exportId}. The export’sdestinationcarrieslocation,readerRoleArn,readerRoleReadyand, when AWS refused the reader,readerRoleError.
To load the files, follow Loading into Snowflake
from the stage onwards: point the stage’s url at the export’s location and
its storage_integration at tessule_export; you need no integration or role
of your own.
What a run writes
Section titled “What a run writes”Paths are relative to the export’s prefix. <table> is the table’s API name
(the name in its /tables/... URL), which never changes.
| Path | What it holds |
|---|---|
<table>/snapshot/run=<run>/part-00001.parquet |
A full snapshot of a table, written once: on the first run, or the first run after the table is added to the export. |
<table>/changes/dt=<date>/run=<run>.parquet |
The table’s record creates, updates and deletes since the previous run. |
_stage_transitions/dt=<date>/run=<run>.parquet |
Stage moves of the exported tables since the previous run. |
_manifest/run=<run>.json |
Written last: every file the run wrote, and every table’s columns. |
- A run’s files are complete when its manifest exists. A run that fails partway is retried whole, under a new run id; its files never overwrite earlier ones.
- Rows can arrive more than once (a retried run, the overlap at a
snapshot’s edge, stage moves re-read at the edge of a run). Every row
carries what you need to discard a repeat: keep the newest
updated_atper record, and one row per stage moveid. - A run reads at most 200,000 change events; anything beyond that is sent by the next run.
- A table with more than 2,000,000 records cannot be snapshotted. The run fails with a message naming the table; leave it out of the export.
Record files
Section titled “Record files”Every record file — snapshot and changes — has the same leading columns, then
one column per exported field, named by the field’s API name. A field whose
name matches a leading column is written as field_<name>.
| Column | Type | Meaning |
|---|---|---|
_op |
string | snapshot, insert, update or delete |
_event_id |
string | The change event; null in a snapshot. |
_logged_at |
timestamp | When the change was logged; null in a snapshot. |
id |
string | The record’s id. |
created_at, updated_at |
timestamp | The record’s own times. updated_at is the version: keep the newest. |
created_by, updated_by, owned_by |
string | User ids. |
A delete row carries the leading columns only (the record’s updated_at as
it was); its field columns are null. A record restored from the recycle bin
arrives as an insert.
Field values take the Parquet type of their field type. Timestamps are UTC.
| Field types | Parquet type |
|---|---|
text, textarea, richtext, email, phone, url, picklist, reference, date, time, autonumber |
string |
datetime |
timestamp |
integer, number, percent, rating, duration |
double |
boolean |
boolean |
currency, multipicklist, address, geolocation, openingHours, recurrence, attachment, polymorphicReference, multiReference, formula, lookup, rollup |
JSON — the value as the API returns it, for example {"amount": 120.5, "currency": "GBP"} |
The manifest’s tables list maps each column to its field id, field type and
Parquet type, so a pipeline can follow a renamed display name or a newly added
field without guessing.
Stage history files
Section titled “Stage history files”One row per stage move (see Lifecycles):
| Column | Meaning |
|---|---|
id |
The move. Unique: keep one row per id. |
table_id, field_id, item_id |
The table, the stage field and the record. |
from_value, to_value |
The stage before and after; from_value is null for a record’s first stage. |
actor_type, actor_id, source |
Who or what moved it. |
created_at |
When the move happened. |
Only moves of exported stage fields are written: leaving a field out of the export leaves out its history too.
The current state of a table
Section titled “The current state of a table”Keep, per record id, the row with the newest updated_at (on a tie, the
newest _logged_at, with snapshot rows last), then drop it if that row is a
delete. In DuckDB, reading the bucket directly:
select *from read_parquet('s3://your-bucket/tessule/sales/deals/**/*.parquet', union_by_name = true)qualify row_number() over ( partition by id order by updated_at desc nulls last, _logged_at desc nulls last ) = 1 and _op <> 'delete';union_by_name lines up files written before and after a field was added.
JSON columns read as JSON, so amount.currency reaches into a currency value.
Loading into Snowflake
Section titled “Loading into Snowflake”The recommended shape is one raw table per exported table, each row kept
whole in a VARIANT, so a field added later never breaks a load. Run this
once, with your own bucket, prefix and Snowflake names:
-- Let Snowflake read the bucket. This is a second role, separate from the-- one the export writes with; DESC INTEGRATION gives the values its trust-- policy needs.create storage integration tessule_s3 type = external_stage storage_provider = 'S3' enabled = true storage_aws_role_arn = 'arn:aws:iam::<your-account-id>:role/snowflake-read' storage_allowed_locations = ('s3://your-bucket/tessule/sales/');
create schema tessule_raw;create file format tessule_raw.parquet type = parquet use_logical_type = true;create stage tessule_raw.export url = 's3://your-bucket/tessule/sales/' storage_integration = tessule_s3 file_format = tessule_raw.parquet;
-- One raw table per exported table, and one for stage history.create table tessule_raw.deals (record variant, _file string, _loaded_at timestamp_ltz default current_timestamp());create table tessule_raw.stage_transitions (record variant, _file string, _loaded_at timestamp_ltz default current_timestamp());Then load on a schedule (a task, or Snowpipe with S3 event notifications).
COPY INTO remembers the files it has loaded, so running it again loads only
new ones:
copy into tessule_raw.deals (record, _file) from (select $1, metadata$filename from @tessule_raw.export/deals/) pattern = '.*[.]parquet';
copy into tessule_raw.stage_transitions (record, _file) from (select $1, metadata$filename from @tessule_raw.export/_stage_transitions/) pattern = '.*[.]parquet';Modelling with dbt
Section titled “Modelling with dbt”Two macros turn a raw table into its current state. Add them to your dbt
project’s macros/ folder:
{% macro tessule_current_state(relation) %}select *from {{ relation }}qualify row_number() over ( partition by record:id::string order by record:updated_at::timestamp_ntz desc nulls last, record:_logged_at::timestamp_ntz desc nulls last ) = 1 and record:_op::string <> 'delete'{% endmacro %}
{% macro tessule_json(expression) -%}iff(is_varchar({{ expression }}), coalesce(try_parse_json({{ expression }}::string), {{ expression }}), {{ expression }}){%- endmacro %}tessule_current_state applies the rule above to a raw table.
tessule_json gives a JSON column as an object or array, whichever way the
load presented it. A model for a table is then a typed select over the
current state, with the raw tables declared as a source:
-- models/deals.sqlwith current as ( {{ tessule_current_state(source('tessule_raw', 'deals')) }})select record:id::string as deal_id, record:name::string as name, get_path({{ tessule_json("record:amount") }}, 'amount')::number(18, 2) as amount, get_path({{ tessule_json("record:amount") }}, 'currency')::string as currency, record:stage::string as stage, record:updated_at::timestamp_ntz as updated_atfrom currentStage history needs no current-state step: keep one row per
record:id and select its columns.
Managing exports
Section titled “Managing exports”The Warehouse exports tab lists every export with its destination, tables, schedule, status and last successful run. Switch off pauses an export without losing its place: switched back on, it carries on from where it stopped. Delete stops it for good; files already in the bucket stay there.
A failing run is retried with a growing delay, up to a day between attempts, and the error is shown on the export’s row until a run succeeds.
The same operations are available through the API, for a workspace token
holding exports:manage: GET /warehouse-exports,
POST /warehouse-exports, GET /warehouse-exports/{exportId},
PATCH /warehouse-exports/{exportId} and
DELETE /warehouse-exports/{exportId}.
Does an export respect record visibility rules?
No. An export sends every record of its tables, whatever any member can see in
the app; that is why creating one needs exports:manage. Leave out fields
that must not leave the workspace.
What happens when I add a table to an existing export? Its next run writes a snapshot of that table, then changes as usual.
What happens when I add a field?
New rows carry its column; older files do not have it. Loading whole rows into
a VARIANT, or reading with union_by_name, handles both.
Can I keep a copy without a warehouse?
Yes. The files are ordinary Parquet: DuckDB, Python (pyarrow, polars) and
Spark read them straight from the bucket.
How do I follow changes without S3?
The change feed (GET /audit/events/feed) serves the same record changes
over the API, page by page from a cursor, for a token that can read the audit
trail. See API access.