Skip to content

test: Add Iceberg test coverage for expire snapshots in Nessie catalog#28155

Open
hantangwangd wants to merge 1 commit into
prestodb:masterfrom
hantangwangd:enhance_test_cases_for_nessie_iceberg
Open

test: Add Iceberg test coverage for expire snapshots in Nessie catalog#28155
hantangwangd wants to merge 1 commit into
prestodb:masterfrom
hantangwangd:enhance_test_cases_for_nessie_iceberg

Conversation

@hantangwangd

@hantangwangd hantangwangd commented Jul 15, 2026

Copy link
Copy Markdown
Member

Description

This PR adds test coverage for the expire_snapshots functionality in Iceberg connector with Nessie catalog.

Motivation and Context

Follow-up from #28083 (comment)

Impact

N/A

Test Plan

Added test cases for expire snapshots in Iceberg with Nessie catalog.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

== NO RELEASE NOTE ==

Summary by Sourcery

Add Nessie-specific coverage and make generic Iceberg snapshot expiration tests work across catalogs with differing GC settings.

Tests:

  • Add a Nessie catalog test verifying expire_snapshots fails by default when GC is disabled.
  • Ensure the generic expire snapshot test explicitly enables gc.enabled so it behaves consistently across all catalogs.

Summary by Sourcery

Add targeted test coverage for Iceberg expire_snapshots behavior in Nessie and ensure generic snapshot expiration tests work consistently across catalogs.

Tests:

  • Add a Nessie catalog test verifying expire_snapshots fails by default when GC is disabled.
  • Update the generic expire snapshot with deleted entries test to explicitly enable gc.enabled so it behaves consistently across different catalogs.

@sourcery-ai

sourcery-ai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds Nessie-specific test coverage for Iceberg snapshot expiration and makes the generic expiration test explicitly enable GC so it works consistently across catalogs.

File-Level Changes

Change Details Files
Add a Nessie-specific test that asserts expire_snapshots fails by default when gc.enabled is false.
  • Introduce a dedicated test method that directly calls the iceberg.system.expire_snapshots procedure against the Nessie catalog.
  • Use assertQueryFails instead of delegating to the base class test and asserting on a RuntimeException.
  • Derive schema from the session and hardcode the target table name to validate the failure message when GC is disabled.
presto-iceberg/src/test/java/com/facebook/presto/iceberg/nessie/TestIcebergDistributedNessie.java
Ensure the generic Iceberg expire snapshot test explicitly enables gc.enabled before expiring snapshots.
  • Update table properties via the Iceberg API to set gc.enabled to true within the test setup.
  • Add explanatory comments documenting why gc.enabled must be explicitly enabled for catalogs like Nessie.
  • Keep the rest of the snapshot expiration logic unchanged to validate expiration behavior with deleted entries.
presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedTestBase.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@hantangwangd hantangwangd marked this pull request as ready for review July 15, 2026 14:07
@hantangwangd hantangwangd requested review from a team, ZacBlanco and imjalpreet as code owners July 15, 2026 14:07

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue, and left some high level feedback:

  • The new Nessie-specific test hardcodes the lineitem table and assumes its presence; consider creating and using a dedicated test table within the test setup to avoid coupling to external data and improve isolation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new Nessie-specific test hardcodes the `lineitem` table and assumes its presence; consider creating and using a dedicated test table within the test setup to avoid coupling to external data and improve isolation.

## Individual Comments

### Comment 1
<location path="presto-iceberg/src/test/java/com/facebook/presto/iceberg/nessie/TestIcebergDistributedNessie.java" line_range="32-33" />
<code_context>
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static java.lang.String.format;

 @Test
 public class TestIcebergDistributedNessie
</code_context>
<issue_to_address>
**suggestion (testing):** Consider expanding the Nessie-specific test to also cover the success path when GC is explicitly enabled

To better exercise Nessie behavior, add a second test that: (1) creates a table, (2) sets `gc.enabled = true` via table properties, then (3) calls `iceberg.system.expire_snapshots` and asserts it succeeds. This will both document the supported way to enable snapshot expiration on Nessie and verify the connector behavior when GC is turned on.

Suggested implementation:

```java
import static com.facebook.presto.iceberg.CatalogType.NESSIE;
import static com.facebook.presto.iceberg.nessie.NessieTestUtil.nessieConnectorProperties;
import static java.lang.String.format;

@Test
public class TestIcebergDistributedNessie

```

Please insert the following new test method into `TestIcebergDistributedNessie` (in the same class as `testExpireSnapshotNotSupportedInNessieByDefault`, e.g. right after it). The method relies on existing helpers like `assertUpdate`, `getQueryRunner()`, and the newly imported `format`:

```java
    @Test
    public void testExpireSnapshotSupportedWhenGcEnabledInNessie()
    {
        String schema = getSession().getSchema().get();
        String tableName = "test_expire_snapshots_gc_enabled";

        // 1. Create a simple Iceberg table in the Nessie catalog
        assertUpdate(format("CREATE TABLE %s.%s (key varchar, value bigint)", schema, tableName));

        // 2. Explicitly enable GC via table properties
        assertUpdate(format("ALTER TABLE %s.%s SET PROPERTIES \"gc.enabled\" = true", schema, tableName));

        // 3. Call expire_snapshots and assert it succeeds (no exception thrown)
        getQueryRunner().execute(format(
                "CALL iceberg.system.expire_snapshots('%s.%s', TIMESTAMP '2000-01-01 00:00:00', 1)",
                schema,
                tableName));

        // Cleanup
        assertUpdate(format("DROP TABLE %s.%s", schema, tableName));
    }
```

Notes:
1. The exact signature of `iceberg.system.expire_snapshots` should match whatever is used in `testExpireSnapshotNotSupportedInNessieByDefault`. If that test uses a different argument list (e.g. named arguments or a different timestamp), mirror that here.
2. If your test base class uses a different helper than `assertUpdate`/`getQueryRunner().execute` (e.g. `assertQuerySucceeds`), adjust the calls accordingly.
3. Keep `gc.enabled` exactly as spelled here (quoted property name) to align with Iceberg’s GC toggle semantics.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 32 to 33
@Test
public class TestIcebergDistributedNessie

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.

suggestion (testing): Consider expanding the Nessie-specific test to also cover the success path when GC is explicitly enabled

To better exercise Nessie behavior, add a second test that: (1) creates a table, (2) sets gc.enabled = true via table properties, then (3) calls iceberg.system.expire_snapshots and asserts it succeeds. This will both document the supported way to enable snapshot expiration on Nessie and verify the connector behavior when GC is turned on.

Suggested implementation:

import static com.facebook.presto.iceberg.CatalogType.NESSIE;
import static com.facebook.presto.iceberg.nessie.NessieTestUtil.nessieConnectorProperties;
import static java.lang.String.format;

@Test
public class TestIcebergDistributedNessie

Please insert the following new test method into TestIcebergDistributedNessie (in the same class as testExpireSnapshotNotSupportedInNessieByDefault, e.g. right after it). The method relies on existing helpers like assertUpdate, getQueryRunner(), and the newly imported format:

    @Test
    public void testExpireSnapshotSupportedWhenGcEnabledInNessie()
    {
        String schema = getSession().getSchema().get();
        String tableName = "test_expire_snapshots_gc_enabled";

        // 1. Create a simple Iceberg table in the Nessie catalog
        assertUpdate(format("CREATE TABLE %s.%s (key varchar, value bigint)", schema, tableName));

        // 2. Explicitly enable GC via table properties
        assertUpdate(format("ALTER TABLE %s.%s SET PROPERTIES \"gc.enabled\" = true", schema, tableName));

        // 3. Call expire_snapshots and assert it succeeds (no exception thrown)
        getQueryRunner().execute(format(
                "CALL iceberg.system.expire_snapshots('%s.%s', TIMESTAMP '2000-01-01 00:00:00', 1)",
                schema,
                tableName));

        // Cleanup
        assertUpdate(format("DROP TABLE %s.%s", schema, tableName));
    }

Notes:

  1. The exact signature of iceberg.system.expire_snapshots should match whatever is used in testExpireSnapshotNotSupportedInNessieByDefault. If that test uses a different argument list (e.g. named arguments or a different timestamp), mirror that here.
  2. If your test base class uses a different helper than assertUpdate/getQueryRunner().execute (e.g. assertQuerySucceeds), adjust the calls accordingly.
  3. Keep gc.enabled exactly as spelled here (quoted property name) to align with Iceberg’s GC toggle semantics.

@imjalpreet imjalpreet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, @hantangwangd. LGTM.

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.

2 participants