Skip to content

feat(services): import parquet history into iceberg tables - #148

Merged
TheMeinerLP merged 4 commits into
mainfrom
feat/import-parquet-history
Nov 21, 2026
Merged

TheMeinerLP merged 4 commits into
mainfrom
feat/import-parquet-history

Conversation

@TheMeinerLP

@TheMeinerLP TheMeinerLP commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Until the switch to Iceberg, every capture was written only to the encrypted Parquet lake. The October captures therefore exist only there, while the dashboards and the training jobs now read the Iceberg tables and see none of them.

This PR adds a one-off command, corvus-import-parquet, that copies the live Parquet files into the Iceberg tables once. Frames and their payloads are decrypted with each player's key and written next to the session end records, so the old captures sit next to the new ones.

Players who were erased are never copied: their rows are skipped, and the run report counts them, as it does rows without a key and sessions the catalog does not know. Session and segment metadata is not copied, because PostgreSQL does not hold the fields the Iceberg tables require for those. Session end records are copied only for sessions that have frames in the lake, and sessions that the live ingest already wrote are left alone.

Running it again is safe. Before a file is written, every row that already exists in the Iceberg table for its date is dropped, so a rerun, a resumed run and a table whose snapshots were expired all copy nothing twice. The dry run reads the same data and writes nothing, so the counts can be checked before the real run. The operator steps for running it once as a Job are in docs/reference/data-lake.md.

Known gap: the compact template does not carry the key secret, so the one-off Job needs the same secret as ingest.

Adds corvus-import-parquet, a one-off copy of the live Parquet lake into
the Iceberg tables (events, raw, session_ends). Raw payloads are decrypted
with the player DEK and joined with their events; erased players and
players without a key are skipped and counted. Each commit is tagged with
its source in the snapshot summary, so reruns and resumes skip what is
already imported. sessions and segments are not imported: their
non-nullable columns are not stored in PostgreSQL.
Describes what the import copies and skips, how reruns stay idempotent
and where that stops (snapshot expiry), and the operator steps for
running it once as a Job.
Snapshot tags expire with the nightly maintenance, so a rerun could copy
everything again. Before a file is appended, rows whose key already exists
in the Iceberg partition of their date are now dropped (session_id and seq
for events and raw, session_id for session_ends). The tag stays as a fast
path only.

session_ends are imported only for sessions with rows in the Parquet files
of their day, and days without Parquet files produce nothing. Ingest has
written capture.session_ends since 2026-11-18, so the Postgres sessions of
that period were duplicated before.
Drops the caveat that the import had to finish within snapshot retention:
rows are now checked against the Iceberg data, so expired snapshot tags
no longer matter. Also states which session_ends are imported.
@TheMeinerLP
TheMeinerLP merged commit 85971d8 into main Nov 21, 2026
14 checks passed
@TheMeinerLP
TheMeinerLP deleted the feat/import-parquet-history branch November 21, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant