rdblue commented on code in PR #5407:
URL: https://github.com/apache/iceberg/pull/5407#discussion_r939733771


##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -284,7 +280,9 @@ public Table loadTable(SessionContext context, 
TableIdentifier identifier) {
             tableFileIO(response.config()),
             response.tableMetadata());
 
-    BaseTable table = new BaseTable(ops, fullTableName(loadedIdent), 
this.scanReporter);
+    BaseTable table =
+        new BaseTable(
+            ops, fullTableName(loadedIdent), new RESTScanReporter(client, 
paths, headers(context)));

Review Comment:
   Rather than having a separate class that gets passed the `RESTClient`, what 
about just using lambda that calls a method in `RESTSessionCatalog`?
   
   ```java
     BaseTable table = new BaseTable(ops, fullTableName(loadedIdent), report -> 
reportScan(report, session::headers));
     ...
   
     private void reportScan(ScanReport report, Supplier<Map<String, String>> 
headers) {
       client.post(
           paths.scanReport(),
           ScanReportRequest.builder().fromScanReport(report).build(),
           null,
           headers,
           ErrorHandlers.defaultErrorHandler());
     }
   ```
   
   That leaks fewer internals of the catalog (like `ResourcePaths`) to other 
objects.
   
   I'd also use `session::headers` rather than `headers(context)` because that 
avoids going through the session cache. We already have the `AuthSession` 
loaded and we also don't want to worry about session expiration.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to