Skip to content

fix: handle missing schema_id in ObjectCache for Iceberg v1 tables#2280

Open
vovacf201 wants to merge 1 commit intoapache:mainfrom
risingwavelabs:fix/handle-missing-schema-id-v1
Open

fix: handle missing schema_id in ObjectCache for Iceberg v1 tables#2280
vovacf201 wants to merge 1 commit intoapache:mainfrom
risingwavelabs:fix/handle-missing-schema-id-v1

Conversation

@vovacf201
Copy link

Which issue does this PR close?

N/A (discovered in production via panic stack trace)

What changes are included in this PR?

ObjectCache::get_manifest_list panics when building the cache key for snapshots that don't have a schema_id set. This happens with Iceberg v1 format tables, where schema_id is optional on snapshots.
The fix falls back to table_metadata.current_schema_id() when snapshot.schema_id() returns None, consistent with how Snapshot::schema() resolves the schema elsewhere in the codebase.

Are these changes tested?

Existing test_get_manifest_list_and_manifest_from_default_cache covers the cache path but uses v2 metadata where schema_id is always present.

ObjectCache::get_manifest_list panics on .unwrap() when building the
cache key for snapshots without a schema_id (Iceberg v1 format tables
don't require this field). Fall back to
table_metadata.current_schema_id() when snapshot.schema_id() is None.
Copy link
Contributor

@blackmwk blackmwk left a comment

Choose a reason for hiding this comment

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

Thanks @vovacf201 for this fix!

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a dir table_metadata under testdata, and we should move it to that dir. We also should rename it to TableMetadataV1SnapshotNoSchemaId

/// the snapshot has no schema_id (Iceberg v1 format tables).
#[tokio::test]
async fn test_get_manifest_list_v1_snapshot_without_schema_id() {
let tmp_dir = TempDir::new().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

There are example above to use TestTableFixture to simplify the tests.

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