jerryshao commented on code in PR #13384:
URL: https://github.com/apache/gravitino/pull/13384#discussion_r4521798046


##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -330,6 +331,23 @@ public LoadTableResponse updateTable(IcebergTableChange 
icebergTableChange) {
     return loadTable(icebergTableChange.getTableIdentifier());
   }
 
+  /**
+   * Builds an {@link IcebergTableChange} and commits it within a single 
proxied call. When this
+   * wrapper is behind the {@link KerberosAwareIcebergCatalogProxy}, the 
entire operation —
+   * including the metadata.json read triggered by {@code loadTable()} inside 
the builder — runs
+   * under the impersonated user's UGI context.
+   *
+   * @param builder a function that uses the underlying catalog to build an 
{@link
+   *     IcebergTableChange}
+   * @return the response after committing the table change
+   */
+  public LoadTableResponse buildAndUpdateTable(Function<Catalog, 
IcebergTableChange> builder) {

Review Comment:
   No test covers the fix: nothing checks that the load and commit run inside 
doKerberosOperations through the proxy. Add a test that calls 
buildAndUpdateTable on a proxied wrapper with a SupportsKerberos catalog and 
asserts the builder runs inside the Kerberos context.



##########
catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/ops/IcebergCatalogWrapperHelper.java:
##########
@@ -232,6 +232,22 @@ private void alterTableColumn(
 
   public IcebergTableChange buildIcebergTableChanges(

Review Comment:
   The old overload still loads the table with the helper's own unproxied 
catalog, so any caller that uses it reads metadata outside impersonation. 
Consider removing it or marking it deprecated so the bug cannot come back.



##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -330,6 +331,23 @@ public LoadTableResponse updateTable(IcebergTableChange 
icebergTableChange) {
     return loadTable(icebergTableChange.getTableIdentifier());
   }
 
+  /**
+   * Builds an {@link IcebergTableChange} and commits it within a single 
proxied call. When this
+   * wrapper is behind the {@link KerberosAwareIcebergCatalogProxy}, the 
entire operation —
+   * including the metadata.json read triggered by {@code loadTable()} inside 
the builder — runs
+   * under the impersonated user's UGI context.
+   *
+   * @param builder a function that uses the underlying catalog to build an 
{@link
+   *     IcebergTableChange}
+   * @return the response after committing the table change
+   */
+  public LoadTableResponse buildAndUpdateTable(Function<Catalog, 
IcebergTableChange> builder) {
+    IcebergTableChange change = builder.apply(getCatalog());
+    Transaction transaction = change.getTransaction();
+    transaction.commitTransaction();
+    return loadTable(change.getTableIdentifier());

Review Comment:
   Unlike the other updateTable overloads, this does not invalidate or refresh 
the table metadata cache after the commit. Is that intended, or could a later 
load return stale metadata?



-- 
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]

Reply via email to