amogh-jahagirdar commented on code in PR #6850:
URL: https://github.com/apache/iceberg/pull/6850#discussion_r1107868937


##########
core/src/test/java/org/apache/iceberg/rest/TestResourcePaths.java:
##########
@@ -128,4 +130,21 @@ public void testTableWithMultipartNamespace() {
     Assert.assertEquals("v1/ws/catalog/namespaces/n%1Fs/tables/table", 
withPrefix.table(ident));
     Assert.assertEquals("v1/namespaces/n%1Fs/tables/table", 
withoutPrefix.table(ident));
   }
+
+  @Test
+  public void testSnapshotParams() {
+    ResourcePaths allSnapshotsPaths =
+        ResourcePaths.forCatalogProperties(
+            ImmutableMap.of("prefix", prefix, "snapshot-loading", "all"));
+    
assertThat(allSnapshotsPaths.snapshotLoading()).isEqualTo(ResourcePaths.SnapshotLoading.ALL);
+    assertThat(allSnapshotsPaths.snapshotLoading().params())
+        .isEqualTo(ImmutableMap.of("snapshots", "all"));
+
+    ResourcePaths refsSnapshotsPaths =
+        ResourcePaths.forCatalogProperties(
+            ImmutableMap.of("prefix", prefix, "snapshot-loading", "refs"));
+    
assertThat(refsSnapshotsPaths.snapshotLoading()).isEqualTo(ResourcePaths.SnapshotLoading.REFS);
+    assertThat(refsSnapshotsPaths.snapshotLoading().params())

Review Comment:
   Nit indentation on 
`assertThat(refsSnapshotsPaths.snapshotLoading().params())`



##########
core/src/test/java/org/apache/iceberg/rest/TestResourcePaths.java:
##########
@@ -128,4 +130,21 @@ public void testTableWithMultipartNamespace() {
     Assert.assertEquals("v1/ws/catalog/namespaces/n%1Fs/tables/table", 
withPrefix.table(ident));
     Assert.assertEquals("v1/namespaces/n%1Fs/tables/table", 
withoutPrefix.table(ident));
   }
+
+  @Test
+  public void testSnapshotParams() {
+    ResourcePaths allSnapshotsPaths =
+        ResourcePaths.forCatalogProperties(
+            ImmutableMap.of("prefix", prefix, "snapshot-loading", "all"));
+    
assertThat(allSnapshotsPaths.snapshotLoading()).isEqualTo(ResourcePaths.SnapshotLoading.ALL);
+    assertThat(allSnapshotsPaths.snapshotLoading().params())

Review Comment:
   Nit: indendation on 
`assertThat(allSnapshotsPaths.snapshotLoading().params())`



##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -302,13 +305,29 @@ public Table loadTable(SessionContext context, 
TableIdentifier identifier) {
     }
 
     AuthSession session = tableSession(response.config(), session(context));
+    TableMetadata tableMetadata;
+
+    if (paths.snapshotLoading() == SnapshotLoading.REFS) {
+      tableMetadata =
+          TableMetadata.buildFrom(response.tableMetadata())
+              .setSnapshotsSupplier(
+                  () ->
+                      loadInternal(context, identifier, SnapshotLoading.ALL)
+                          .tableMetadata()
+                          .snapshots())
+              .discardChanges()
+              .build();

Review Comment:
   Sorry maybe silly question, not entirely following why we have this special 
case when the loading mode is `REFS`?



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