gaborkaszab commented on code in PR #12194:
URL: https://github.com/apache/iceberg/pull/12194#discussion_r2284700220


##########
core/src/main/java/org/apache/iceberg/rest/ETagProvider.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.rest;
+
+import org.apache.iceberg.rest.responses.LoadTableResponse;
+
+/** Interface for creating the content of the ETag HTTP headers */
+public interface ETagProvider {

Review Comment:
   removed the interface and kept the utility class with a static method



##########
core/src/test/java/org/apache/iceberg/rest/DefaultETagProvider.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.rest;
+
+import java.nio.charset.StandardCharsets;
+import org.apache.iceberg.relocated.com.google.common.hash.HashFunction;
+import org.apache.iceberg.relocated.com.google.common.hash.Hashing;
+import org.apache.iceberg.rest.responses.LoadTableResponse;
+
+public class DefaultETagProvider implements ETagProvider {

Review Comment:
   done



##########
core/src/test/java/org/apache/iceberg/rest/DefaultETagProvider.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.rest;
+
+import java.nio.charset.StandardCharsets;
+import org.apache.iceberg.relocated.com.google.common.hash.HashFunction;
+import org.apache.iceberg.relocated.com.google.common.hash.Hashing;
+import org.apache.iceberg.rest.responses.LoadTableResponse;
+
+public class DefaultETagProvider implements ETagProvider {
+  private static final HashFunction MURMUR3 = Hashing.murmur3_32_fixed();
+
+  @Override
+  public String of(LoadTableResponse resp) {

Review Comment:
   thanks @nastra @dramaticlly ! changed the parameter to metadata location



##########
core/src/test/java/org/apache/iceberg/rest/RESTCatalogAdapter.java:
##########
@@ -285,9 +288,19 @@ public RESTClient withAuthSession(AuthSession session) {
     return this;
   }
 
+  public RESTClient withETagProvider(ETagProvider eTagProv) {

Review Comment:
   done



##########
core/src/test/java/org/apache/iceberg/rest/DefaultETagProvider.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.rest;
+
+import java.nio.charset.StandardCharsets;
+import org.apache.iceberg.relocated.com.google.common.hash.HashFunction;
+import org.apache.iceberg.relocated.com.google.common.hash.Hashing;
+import org.apache.iceberg.rest.responses.LoadTableResponse;
+
+public class DefaultETagProvider implements ETagProvider {
+  private static final HashFunction MURMUR3 = Hashing.murmur3_32_fixed();
+
+  @Override
+  public String of(LoadTableResponse resp) {

Review Comment:
   done



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2698,6 +2706,133 @@ public void 
testTableExistsFallbackToGETRequestWithLegacyServer() {
     verifyTableExistsFallbackToGETRequest(ConfigResponse.builder().build());
   }
 
+  @Test
+  public void testETagCreateTableAndLoadTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isEqualTo(respHeaders.get(HttpHeaders.ETAG));
+    respHeaders.clear();
+  }
+
+  @Test
+  public void testETagDifferentTables() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTagTbl1 = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.createTable(TableIdentifier.of(TABLE.namespace(), "table2"), 
SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTagTbl1).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagAfterDataUpdate() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    tbl.newAppend().appendFile(FILE_A).commit();
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagAfterMetadataOnlyUpdate() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    tbl.updateSchema().addColumn("extra", Types.IntegerType.get()).commit();
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagRegisterTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.registerTable(
+        TableIdentifier.of(TABLE.namespace(), "other_table"),
+        ((BaseTable) tbl).operations().current().metadataFileLocation());
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);

Review Comment:
   thx, done



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2698,6 +2706,133 @@ public void 
testTableExistsFallbackToGETRequestWithLegacyServer() {
     verifyTableExistsFallbackToGETRequest(ConfigResponse.builder().build());
   }
 
+  @Test
+  public void testETagCreateTableAndLoadTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isEqualTo(respHeaders.get(HttpHeaders.ETAG));
+    respHeaders.clear();
+  }
+
+  @Test
+  public void testETagDifferentTables() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTagTbl1 = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.createTable(TableIdentifier.of(TABLE.namespace(), "table2"), 
SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTagTbl1).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagAfterDataUpdate() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    tbl.newAppend().appendFile(FILE_A).commit();
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagAfterMetadataOnlyUpdate() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    tbl.updateSchema().addColumn("extra", Types.IntegerType.get()).commit();
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagRegisterTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.registerTable(
+        TableIdentifier.of(TABLE.namespace(), "other_table"),
+        ((BaseTable) tbl).operations().current().metadataFileLocation());
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  private RESTCatalog setUpETagTest(Map<String, String> respHeaders) {

Review Comment:
   done



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2698,6 +2706,133 @@ public void 
testTableExistsFallbackToGETRequestWithLegacyServer() {
     verifyTableExistsFallbackToGETRequest(ConfigResponse.builder().build());
   }
 
+  @Test
+  public void testETagCreateTableAndLoadTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isEqualTo(respHeaders.get(HttpHeaders.ETAG));
+    respHeaders.clear();
+  }
+
+  @Test
+  public void testETagDifferentTables() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTagTbl1 = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.createTable(TableIdentifier.of(TABLE.namespace(), "table2"), 
SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTagTbl1).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagAfterDataUpdate() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    tbl.newAppend().appendFile(FILE_A).commit();
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagAfterMetadataOnlyUpdate() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    tbl.updateSchema().addColumn("extra", Types.IntegerType.get()).commit();
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagRegisterTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.registerTable(
+        TableIdentifier.of(TABLE.namespace(), "other_table"),
+        ((BaseTable) tbl).operations().current().metadataFileLocation());
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  private RESTCatalog setUpETagTest(Map<String, String> respHeaders) {
+    RESTCatalogAdapter adapter =
+        new RESTCatalogAdapter(backendCatalog) {
+          @Override
+          public <T extends RESTResponse> T execute(
+              HTTPRequest request,
+              Class<T> responseType,
+              Consumer<ErrorResponse> errorHandler,
+              Consumer<Map<String, String>> responseHeaders) {
+            return super.execute(request, responseType, errorHandler, 
respHeaders::putAll);
+          }
+        };
+
+    RESTCatalog catalog = catalog(adapter);
+
+    if (requiresNamespaceCreate()) {

Review Comment:
   done



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2698,6 +2706,133 @@ public void 
testTableExistsFallbackToGETRequestWithLegacyServer() {
     verifyTableExistsFallbackToGETRequest(ConfigResponse.builder().build());
   }
 
+  @Test
+  public void testETagCreateTableAndLoadTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isEqualTo(respHeaders.get(HttpHeaders.ETAG));

Review Comment:
   indeed, done



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2698,6 +2706,133 @@ public void 
testTableExistsFallbackToGETRequestWithLegacyServer() {
     verifyTableExistsFallbackToGETRequest(ConfigResponse.builder().build());
   }
 
+  @Test
+  public void testETagCreateTableAndLoadTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isEqualTo(respHeaders.get(HttpHeaders.ETAG));
+    respHeaders.clear();
+  }
+
+  @Test
+  public void testETagDifferentTables() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTagTbl1 = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.createTable(TableIdentifier.of(TABLE.namespace(), "table2"), 
SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTagTbl1).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagAfterDataUpdate() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);

Review Comment:
   done



##########
core/src/test/java/org/apache/iceberg/rest/RESTCatalogAdapter.java:
##########
@@ -392,8 +405,9 @@ public <T extends RESTResponse> T handleRequest(
             return castResponse(
                 responseType, CatalogHandlers.stageTableCreate(catalog, 
namespace, request));

Review Comment:
   I wasn't sure here. Isn't the metadata location null for stage create? I 
created a simple test and it was null there, so I don't think we can add an 
ETag here. Do I miss something?



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2698,6 +2706,133 @@ public void 
testTableExistsFallbackToGETRequestWithLegacyServer() {
     verifyTableExistsFallbackToGETRequest(ConfigResponse.builder().build());
   }
 
+  @Test
+  public void testETagCreateTableAndLoadTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isEqualTo(respHeaders.get(HttpHeaders.ETAG));
+    respHeaders.clear();

Review Comment:
   oops, left it here after I've split up the test. done



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2698,6 +2706,133 @@ public void 
testTableExistsFallbackToGETRequestWithLegacyServer() {
     verifyTableExistsFallbackToGETRequest(ConfigResponse.builder().build());
   }
 
+  @Test
+  public void testETagCreateTableAndLoadTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isEqualTo(respHeaders.get(HttpHeaders.ETAG));
+    respHeaders.clear();
+  }
+
+  @Test
+  public void testETagDifferentTables() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTagTbl1 = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    catalog.createTable(TableIdentifier.of(TABLE.namespace(), "table2"), 
SCHEMA);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTagTbl1).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagAfterDataUpdate() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    tbl.newAppend().appendFile(FILE_A).commit();
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagAfterMetadataOnlyUpdate() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);
+
+    respHeaders.clear();
+
+    Table tbl = catalog.loadTable(TABLE);
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    String eTag = respHeaders.get(HttpHeaders.ETAG);
+    respHeaders.clear();
+
+    tbl.updateSchema().addColumn("extra", Types.IntegerType.get()).commit();
+
+    assertThat(respHeaders).containsKey(HttpHeaders.ETAG);
+    assertThat(eTag).isNotEqualTo(respHeaders.get(HttpHeaders.ETAG));
+  }
+
+  @Test
+  public void testETagRegisterTable() {
+    Map<String, String> respHeaders = Maps.newConcurrentMap();
+
+    RESTCatalog catalog = setUpETagTest(respHeaders);
+
+    catalog.createTable(TABLE, SCHEMA);

Review Comment:
   done



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to