Skip to content

[#9736][followup] feat(iceberg-rest): Add ETag header to registerTable response#10641

Merged
roryqi merged 6 commits intoapache:mainfrom
laserninja:fix/9736-register-table-etag-consistency
Apr 6, 2026
Merged

[#9736][followup] feat(iceberg-rest): Add ETag header to registerTable response#10641
roryqi merged 6 commits intoapache:mainfrom
laserninja:fix/9736-register-table-etag-consistency

Conversation

@laserninja
Copy link
Copy Markdown
Collaborator

What changes were proposed in this pull request?

Add ETag header to the registerTable response for consistency with createTable and updateTable, which already include ETags. This was identified by @roryqi in #10536 (comment).

Why are the changes needed?

The registerTable endpoint returns a LoadTableResponse but did not include an ETag header, unlike createTable and updateTable. This meant clients could not reuse ETags from registerTable for subsequent conditional loadTable requests (If-None-Match), breaking ETag consistency across all endpoints that return LoadTableResponse.

Does this PR introduce any user-facing change?

No user-facing API changes. The registerTable response now includes an ETag header when the table metadata has a metadata file location.

How was this patch tested?

  • Added testRegisterTableReturnsETag test verifying ETag presence in registerTable response.
  • Updated test mock (CatalogWrapperForTest) to return TableMetadata with a metadataFileLocation so ETag can be generated.
  • All existing ETag and namespace tests pass.

…erTable response

Include ETag header in the registerTable response for consistency
with createTable and updateTable, which already include ETags.

This ensures clients can reuse ETags across all endpoints that
return LoadTableResponse, as specified by the Iceberg REST spec.
@laserninja
Copy link
Copy Markdown
Collaborator Author

  1. Moved ETag helpers to IcebergRESTUtils: generateETag() and buildResponseWithETag() now live in IcebergRESTUtils as public static methods. IcebergTableOperations delegates to them via private wrappers. IcebergNamespaceOperations calls IcebergRESTUtils.buildResponseWithETag() directly. No more cross-class package-private access.

  2. Added ETag value assertion: testRegisterTableReturnsETag now computes the expected SHA-256 from the known mock metadata location (/mock/metadata/v1.metadata.json + "all") and asserts the exact ETag value matches.

…te constants

- Return Optional<EntityTag> instead of null from generateETag methods
- Use DEFAULT_SNAPSHOTS instead of null in single-arg generateETag
- Move SNAPSHOTS_REFS constant to IcebergRESTUtils alongside DEFAULT_SNAPSHOTS
- Update all callers to handle Optional properly
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Code Coverage Report

Overall Project 65.19% +0.07% 🟢
Files changed 79.85% 🟢

Module Coverage
aliyun 1.73% 🔴
api 47.14% 🟢
authorization-common 85.96% 🟢
aws 1.1% 🔴
azure 2.6% 🔴
catalog-common 10.0% 🔴
catalog-fileset 80.02% 🟢
catalog-hive 80.98% 🟢
catalog-jdbc-clickhouse 79.06% 🟢
catalog-jdbc-common 42.89% 🟢
catalog-jdbc-doris 80.28% 🟢
catalog-jdbc-hologres 54.03% 🟢
catalog-jdbc-mysql 79.23% 🟢
catalog-jdbc-oceanbase 78.38% 🟢
catalog-jdbc-postgresql 82.05% 🟢
catalog-jdbc-starrocks 78.27% 🟢
catalog-kafka 77.01% 🟢
catalog-lakehouse-generic 45.07% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 87.15% 🟢
catalog-lakehouse-paimon 77.71% 🟢
catalog-model 77.72% 🟢
cli 44.51% 🟢
client-java 77.63% 🟢
common 49.42% 🟢
core 81.4% 🟢
filesystem-hadoop3 76.97% 🟢
flink 40.55% 🟢
flink-runtime 0.0% 🔴
gcp 14.2% 🔴
hadoop-common 10.39% 🔴
hive-metastore-common 45.82% 🟢
iceberg-common 50.0% 🟢
iceberg-rest-server 66.93% +2.04% 🟢
integration-test-common 0.0% 🔴
jobs 66.17% 🟢
lance-common 23.88% 🔴
lance-rest-server 57.84% 🟢
lineage 53.02% 🟢
optimizer 82.87% 🟢
optimizer-api 21.95% 🔴
server 85.63% 🟢
server-common 70.23% 🟢
spark 32.79% 🔴
spark-common 39.09% 🔴
trino-connector 33.83% 🔴
Files
Module File Coverage
iceberg-rest-server IcebergTableOperations.java 81.91% 🟢
IcebergRESTUtils.java 77.91% 🟢
IcebergNamespaceOperations.java 77.57% 🟢

Copy link
Copy Markdown
Contributor

@roryqi roryqi left a comment

Choose a reason for hiding this comment

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

LGTM

@roryqi roryqi merged commit 9c03883 into apache:main Apr 6, 2026
29 checks passed
bbiiaaoo pushed a commit to bbiiaaoo/gravitino that referenced this pull request Apr 7, 2026
…erTable response (apache#10641)

### What changes were proposed in this pull request?

Add ETag header to the `registerTable` response for consistency with
`createTable` and `updateTable`, which already include ETags. This was
identified by @roryqi in [apache#10536
(comment)](apache#10536 (comment)).

### Why are the changes needed?

The `registerTable` endpoint returns a `LoadTableResponse` but did not
include an ETag header, unlike `createTable` and `updateTable`. This
meant clients could not reuse ETags from `registerTable` for subsequent
conditional `loadTable` requests (`If-None-Match`), breaking ETag
consistency across all endpoints that return `LoadTableResponse`.

### Does this PR introduce _any_ user-facing change?

No user-facing API changes. The `registerTable` response now includes an
`ETag` header when the table metadata has a metadata file location.

### How was this patch tested?

- Added `testRegisterTableReturnsETag` test verifying ETag presence in
`registerTable` response.
- Updated test mock (`CatalogWrapperForTest`) to return `TableMetadata`
with a `metadataFileLocation` so ETag can be generated.
- All existing ETag and namespace tests pass.
babumahesh pushed a commit to babumahesh/gravitino that referenced this pull request Apr 9, 2026
…erTable response (apache#10641)

### What changes were proposed in this pull request?

Add ETag header to the `registerTable` response for consistency with
`createTable` and `updateTable`, which already include ETags. This was
identified by @roryqi in [apache#10536
(comment)](apache#10536 (comment)).

### Why are the changes needed?

The `registerTable` endpoint returns a `LoadTableResponse` but did not
include an ETag header, unlike `createTable` and `updateTable`. This
meant clients could not reuse ETags from `registerTable` for subsequent
conditional `loadTable` requests (`If-None-Match`), breaking ETag
consistency across all endpoints that return `LoadTableResponse`.

### Does this PR introduce _any_ user-facing change?

No user-facing API changes. The `registerTable` response now includes an
`ETag` header when the table metadata has a metadata file location.

### How was this patch tested?

- Added `testRegisterTableReturnsETag` test verifying ETag presence in
`registerTable` response.
- Updated test mock (`CatalogWrapperForTest`) to return `TableMetadata`
with a `metadataFileLocation` so ETag can be generated.
- All existing ETag and namespace tests pass.
babumahesh added a commit to babumahesh/gravitino that referenced this pull request Apr 9, 2026
babumahesh added a commit to babumahesh/gravitino that referenced this pull request Apr 9, 2026
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.

3 participants