Skip to content

count() and plan_files() return nothing for an expired snapshot id #4197

Open

Description

@RyanLin5967

Apache Iceberg version

0.12.0 (latest release)

Please describe the bug 🐞

Currently, plan_files() returns no tasks when the scan's snapshot_id names no snapshot, so count() of an expired snapshot is 0. to_arrow() on the same scan raises.

import tempfile
import pyarrow as pa
from pyiceberg.catalog.sql import SqlCatalog

cat = SqlCatalog("c", uri="sqlite:///:memory:", warehouse=f"file://{tempfile.mkdtemp()}")
cat.create_namespace("ns")
t = cat.create_table("ns.t", schema=pa.schema([("x", pa.int64())]))
t.append(pa.table({"x": [1, 2]}))
s1 = t.current_snapshot().snapshot_id
t.append(pa.table({"x": [3]}))
t.maintenance.expire_snapshots().by_id(s1).commit()

print(t.scan(snapshot_id=s1).count(), list(t.scan(snapshot_id=s1).plan_files()))
# 0 [], should raise like to_arrow()

t.scan(snapshot_id=s1).to_arrow()
# ValueError: Snapshot not found: 295003531889393679

An id the table never had does the same.

tested on pyiceberg 0.12.0 and main

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Activity

  1. dragonknightk commented on Oct 31, 2026

    @dragonknightk

    Thanks for the report and the clear repro! I've opened #4218 for this and I'm taking it (´。• ᵕ •。) plan_files()andcount()now raiseSnapshot not foundfor an id that is not in the metadata, the same errorto_arrow()` already raises ʕ•ᴥ•ʔ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy