Skip to content

[Nessie REST Catalog] Iceberg table not listing all snapshots #1105

Closed

Description

@PetrasTYR

Question

Hello, I have a question regarding iceberg table snapshots. I used pyiceberg to create a namespace and a table, then insert a dataframe like so:

from pyiceberg.catalog import load_rest
from pyiceberg.schema import Schema
from pyiceberg.types import StringType, NestedField, DoubleType
from pyiceberg.partitioning import PartitionSpec, PartitionField
import numpy as np
import pandas as pd

rows = 10**1
ncols = 10
countries = ["US", "CA", "UK"]
attr2 = ["OPEN", "CLOSE", "LOW", "HIGH"]
dates = pd.date_range("2020-01-01", "2020-12-31")
data_orig = pd.DataFrame(
    [
        {
            "countries": countries[i % len(countries)],
            "status": attr2[i % len(attr2)],
            "return_index": np.random.rand(),
        }
        for i in range(rows)
    ]
)

schema = Schema(
    NestedField(field_id=1, name="countries", field_type=StringType(), required=False),
    NestedField(field_id=2, name="status", field_type=StringType(), required=False),
    NestedField(
        field_id=3, name="return_index", field_type=DoubleType(), required=False
    ),
)
partition_spec = PartitionSpec(
    fields=[
        PartitionField(
            source_id=1, field_id=1000, name="countries", transform="identity"
        ),
        PartitionField(source_id=2, field_id=1001, name="status", transform="identity"),
    ]
)
catalog = load_rest(
    "rest",
    conf={
        "uri": "http://localhost:19120/iceberg",
    },
)
catalog.create_namespace_if_not_exists("rpmd")
tables = catalog.list_tables(namespace="rpmd")

table = catalog.create_table_if_not_exists(
    identifier="rpmd.performance", schema=schema, partition_spec=partition_spec
)
import pyarrow as pa
import pyarrow.parquet as pq

tbl = pa.Table.from_pandas(data_orig)
table.append(tbl)

When i run this script a second time, it is my understanding that the append method would create a new commit, and in turn, a new snapshot of the rpmd.performance iceberg table, and i should be able to see a list of snapshots in the latest metadata.json file. However, i only see the latest snapshot in the array, and running table.inspect.snapshots() only shows 1 snapshot_id, even though i see all the relevant .avro files.

May i know if there is some configuration i need to do to ensure that i can see all snapshots?

Activity

  1. changed the title [-]Iceberg table not keeping track of snapshots[/-] [+]Iceberg table not listing all snapshots[/+] on Aug 27, 2024
  2. PetrasTYR commented on Aug 28, 2024

    @PetrasTYR
    Author

    For some additional background information:

    i am using Nessie's REST APIs for iceberg tables.

    package versions:

    python = "^3.11"
    pyarrow = "^17.0.0"
    pyiceberg = "^0.7.1"
    pandas = "^2.2.2"
    

    in the latest metadata.json file, this is how the snapshots section look like:

    "snapshots": [
            {
                "sequence-number": 3,
                "snapshot-id": 1182955948280775518,
                "timestamp-ms": 1724830740048,
                "summary": {
                    "operation": "append",
                    "added-files-size": "82710797",
                    "added-data-files": "12",
                    "added-records": "10000000",
                    "changed-partition-count": "12",
                    "total-data-files": "32",
                    "total-delete-files": "0",
                    "total-records": "10000020",
                    "total-files-size": "82740483",
                    "total-position-deletes": "0",
                    "total-equality-deletes": "0"
                },
                "manifest-list": "s3://tablestore-bucket/rpmd/performance_7fab8ae5-29b9-48cf-9cf2-b8c36478653f/metadata/snap-1182955948280775518-0-39fe1f0d-8c8f-4f4d-9fbf-1fd74b0a52cf.avro",
                "schema-id": 0
            }
        ],
    

    the sequence number is being tracked correctly but only the latest snapshot is being saved. my understanding is that all the past snapshots should be saved.

  3. sungwy commented on Aug 28, 2024

    @sungwy
    Collaborator

    Hi @PetrasTYR , thank you for reporting this issue, and continuing the investigation on your side. The follow-up comment you posted is indeed very helpful. It looks like the latest metadata file only has a single snapshot, which makes me wonder if this is an issue with the specific implementation of the REST Catalog.

    What you expect is correct. We should expect to see two snapshots, each snapshot with different snapshot-id but with the same snapshot summary since you are repeating the same operation twice.

  4. PetrasTYR commented on Aug 28, 2024

    @PetrasTYR
    Author

    Hi @sungwy , were you able to replicate the issue, by any chance?

  5. PetrasTYR commented on Aug 28, 2024

    @PetrasTYR
    Author

    Hello, I was asking some folks at project nessie's zulip chat and it seems like this is expected. Nessie provides catalog level versioning providing a consistent and reproducible state across the whole catalog; and to retain Nessie’s consistency and cross-branch/tag isolation guarantees, they deliberately choose to only return the state of a table or view as a single snapshot in Iceberg i.e. Nessie intentionally only returns the latest snapshot. Anything related to time-travel queries are to be done via Nessie instead of directly through Iceberg!

  6. sungwy commented on Aug 28, 2024

    @sungwy
    Collaborator

    That's good to know! I didn't know much about Nessie, but I think this is helpful information for anyone else looking to debug this issue in the future. Thank you again for raising this issue and following up with the findings @PetrasTYR !

  7. PetrasTYR commented on Aug 28, 2024

    @PetrasTYR
    Author

    No worries! Closing this issue for now~

  8. changed the title [-]Iceberg table not listing all snapshots[/-] [+][Nessie REST Catalog] Iceberg table not listing all snapshots[/+] on Aug 30, 2024
  9. kevinjqliu commented on Aug 30, 2024

    @kevinjqliu
    Contributor

    Updated title for future reference

  10. kevinjqliu commented on Jan 13, 2025

    @kevinjqliu
    Contributor

    To retain Nessie’s consistency and cross-branch/tag isolation guarantees, we have deliberately chosen to only return the state of a table or view as a single snapshot in Iceberg.

    https://projectnessie.org/guides/iceberg-rest/#time-travel-with-iceberg-rest

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions