Skip to content

feat(rest): support freshness-aware table loading - #3377

Open
YuangGao wants to merge 2 commits into
apache:mainfrom
YuangGao:feat/rest-freshness-aware-load
Open

YuangGao wants to merge 2 commits into
apache:mainfrom
YuangGao:feat/rest-freshness-aware-load

Conversation

@YuangGao

@YuangGao YuangGao commented Oct 9, 2026 •

Copy link
Copy Markdown

Which issue does this PR close?

What changes are included in this PR?

load_table never sent If-None-Match and parsed a body-less 304 as a 200. Following Java (apache/iceberg#14398):

  • Cache tables loaded with an ETag, keyed by session and identifier; a later load sends If-None-Match and returns the cached table on 304.
  • Add rest-table-cache.max-entries (default 100, 0 disables) and rest-table-cache.expire-after-write-ms (default 5 minutes).

Only load responses fill the cache, as in Java: the reference server's ETag also covers query parameters, so a create response's never matches a later load.

Are these changes tested?

  • Unit tests with mockito.
  • Verified against apache/iceberg-rest-fixture:latest: loads return 200 then 304; after a commit, drop or re-create, the stale ETag yields 200 or 404 instead of the cached table.

AI Disclosure

  • AI-assisted implementation.

Comment thread crates/catalog/rest/src/catalog.rs Outdated
};
Ok(TableCache::builder()
.max_capacity(parse(REST_CATALOG_PROP_TABLE_CACHE_MAX_ENTRIES, 100)?)
.time_to_live(Duration::from_millis(parse(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Compared with Java's RESTTableCache: the property names, defaults, the (session id, identifier) key and the 304 handling all match. One difference: Java rejects rest-table-cache.expire-after-write-ms of 0 (Preconditions.checkArgument(expireAfterWriteMS > 0, "Invalid expire after write: zero or negative")), while here 0 is accepted. Should this reject 0 too, or document what 0 does?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

good catch, thanks. 0 is now rejected like in Java, since it's ambiguous (disable vs never expire) and max-entries=0 already turns the cache off. while there, also capped it at 1000 years, which moka would otherwise panic on.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks, the upper bound is a nice catch too.

This branch has not been deployed

No deployments
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.

RestCatalog: support freshness-aware table loading (If-None-Match / 304 Not Modified), as Iceberg Java does

2 participants