Skip to content

Delta Lake export: LEFT JOIN the segmentation table - #279

Open
bdpedigo wants to merge 2 commits into
masterfrom
deltalake-export-left-join
Open

bdpedigo wants to merge 2 commits into
masterfrom
deltalake-export-left-join

Conversation

@bdpedigo

Copy link
Copy Markdown
Contributor

Closes #275.

Cherry-picks 83bfb70 from `deltalake-version-export` onto `master`.

The Delta Lake exporter joined the annotation table to its segmentation table with an inner join. An annotation with no segmentation row was dropped from the export. The query API's `QueryManager` uses a LEFT JOIN and keeps such rows with null supervoxel and root ids, and `MaterializedMetadata` counts them. This change makes the exporter use a LEFT JOIN in `TableSource.from_clause` and in the `row_limit` path of `stream_table_to_arrow`.

Tests: updates the `TableSource` assertion and adds `TestStreamKeepsAnnotationsWithoutSegmentation`, which runs against Postgres.

🤖 Generated with Claude Code

… does

An annotation whose supervoxel lookup produced no segmentation row is still a
row of the table: QueryManager's LEFT JOIN returns it with null ids, and
MaterializedMetadata counts it. The exporter's inner join dropped such rows
silently. The new catalog row-count check caught it on ltv7 v2253, where
spine_bigger_test_4 lost 247 of its 1,499,995 rows in all three lakes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runner's pg_dump (17+) writes SET transaction_timeout, which a
Postgres 13 server rejects. The --single-transaction psql import then
aborts and test_clustered_staging_table_transfers_in_id_order sees 0
rows. The production image installs postgresql-client-18.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The accompanying PostGIS/PostgreSQL CI upgrade from 13 to 18 requires runtime validation of pg_dump/psql transfer tests and runner-client compatibility, which was unavailable during review.

No open issues 🎉

What changed in this PR

Updates Delta Lake exports to retain annotations without segmentation rows, matching the query API’s behavior and preserving null segmentation IDs.

Changes:

  • Uses LEFT JOIN for both standard and row-limited exports.
  • Adds a Postgres regression test covering unmatched annotations in both paths.
  • Updates the CI database image to PostgreSQL 18 with PostGIS 3.6.
File Description
tests/​test_deltalake_export.py Updates the join assertion and tests retention of unmatched annotations.
materializationengine/​workflows/​deltalake_export.py Changes both annotation-to-segmentation joins to LEFT JOIN.
.github/​workflows/​materialization_ci.yml Updates the PostGIS service image to 18-3.6.

Review effort: Balanced

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.

Use a left join between base and segmentation table during delta lake exports

4 participants