dennismdejong opened a new pull request, #13708:
URL: https://github.com/apache/gravitino/pull/13708
### What changes were proposed in this pull request?
`loadTable` already implemented ETag-based conditional loading
(`If-None-Match`, ETag generation, `304 Not Modified`), but `loadView`
returned the full response unconditionally. This closes that gap:
- Generate a view ETag from the view metadata file location
(`ViewMetadata.metadataFileLocation()`), hashed with a view-specific salt
so
a view ETag can never collide with the ETag a table would get for the same
location. Views have no `snapshots` query parameter, so the table salt
cannot
be reused.
- `loadView` now accepts `If-None-Match` and returns `304 Not Modified` (with
the ETag header, without a body) when it matches the current view version.
- `200` responses carry the `ETag` header so clients can reuse it for
subsequent conditional loads.
- The `If-None-Match` comparison and the `200 + ETag` response building moved
into `IcebergRESTUtils`, so `loadTable` and `loadView` share one
implementation instead of duplicating it.
### Why are the changes needed?
Spec-coverage/caching inconsistency: the Iceberg REST spec allows conditional
loading for views, and clients that poll `loadView` currently always transfer
the full view metadata even when nothing changed.
Fix: #11582
### Does this PR introduce _any_ user-facing change?
Yes: the Iceberg REST `GET /v1/{prefix}/namespaces/{namespace}/views/{view}`
endpoint now honors `If-None-Match` and returns `304 Not Modified` with an
`ETag` header on 200 responses. No configuration or API signature changes.
### How was this patch tested?
Added tests to `TestIcebergViewOperations`: ETag present and stable on
repeated loads, `304` on a matching `If-None-Match`, `200` on a non-matching
value, and ETag rotation after `replaceView` (including that the stale ETag
no
longer yields `304`). Added unit tests to `TestIcebergRESTUtils` for
`generateViewETag` (determinism, no collision with table ETags, blank input),
`buildResponseWithETag(LoadViewResponse)` and `etagMatches`.
Ran `./gradlew :iceberg:iceberg-rest-server:test
:iceberg:iceberg-rest-server:spotlessCheck`:
516 tests, all pass except the pre-existing environment-only failure of the
Docker-dependent `IcebergRESTAsyncPurgeIT` (`ITUtils.cleanDisk` needs the
Linux
`free` binary).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]