wombatu-kun commented on code in PR #16910:
URL: https://github.com/apache/iceberg/pull/16910#discussion_r3791840098
##########
core/src/test/java/org/apache/iceberg/TestRewriteTablePathUtil.java:
##########
@@ -376,4 +385,70 @@ private ManifestFile
deleteManifestWithLiveAndDeletedEntry(DeleteFile live, Dele
return writer.toManifestFile();
}
+
+ /**
+ * One manifest is measured and one is not, in a single manifest list. The
measured one must take
+ * the mapped length and the unmeasured one must keep its source length,
which pins both the
+ * stamping and the fact that the map is keyed by the source path, not the
rewritten one.
+ */
+ @TestTemplate
+ public void testRewriteManifestListStampsMeasuredManifestLengths() throws
IOException {
+ table.newFastAppend().appendFile(FILE_A).commit();
+ table.newFastAppend().appendFile(FILE_B).commit();
+ Snapshot snapshot = table.currentSnapshot();
+ List<ManifestFile> manifests = snapshot.allManifests(table.io());
+ assertThat(manifests).hasSize(2);
+ ManifestFile measured = manifests.get(0);
+ ManifestFile unmeasured = manifests.get(1);
+
+ String manifestPath = measured.path();
+ String sourcePrefix = manifestPath.substring(0,
manifestPath.indexOf("/metadata/"));
+ String targetPrefix = sourcePrefix + "/relocated";
+ String stagingDir = temp.resolve("staging").toString();
+ String outputPath = temp.resolve("rewritten-list-" + System.nanoTime() +
".avro").toString();
+
+ // a value distinct from the source length so we can tell it was applied
+ long rewrittenLength = measured.length() + 4242L;
+
+ RewriteTablePathUtil.rewriteManifestList(
+ snapshot,
+ table.io(),
+ table.ops().current(),
+ manifests,
+ Set.of(measured.path(), unmeasured.path()),
+ sourcePrefix,
+ targetPrefix,
+ stagingDir,
+ outputPath,
+ Map.of(measured.path(), rewrittenLength));
Review Comment:
Done 90d25bf7d
--
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]