-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spark-3.3: Handle no-op for rewrite manifests procedure/action #6695
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,10 @@ private RewriteManifests.Result doExecute() { | |
int targetNumManifests = targetNumManifests(totalSizeBytes); | ||
int targetNumManifestEntries = targetNumManifestEntries(numEntries, targetNumManifests); | ||
|
||
if (targetNumManifests == 1 && matchingManifests.size() == 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is safe as the only manifest that may match may be huge, which would be a bottleneck for planning. It is a valid scenario to be able to split one giant manifest into a number of smaller ones. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can skip this iff the size of the manifest is under the target manifest size. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will need tests for both scenarios. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rewriting one big manifest into smaller manifests still works with this change and we have testcases for it. We already have tests for both scenario's in this file it is called |
||
return BaseRewriteManifestsActionResult.empty(); | ||
} | ||
|
||
Dataset<Row> manifestEntryDF = buildManifestEntryDF(matchingManifests); | ||
|
||
List<ManifestFile> newManifests; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,6 +341,10 @@ public void testRewriteImportedManifests() throws IOException { | |
SparkTableUtil.importSparkTable( | ||
spark, new TableIdentifier("parquet_table"), table, stagingDir.toString()); | ||
|
||
// add some more data to create more than one manifest for the rewrite | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was a 1-to-1 no-op. So, added one more manifest to avoid no-op. |
||
inputDF.select("c1", "c2", "c3").write().format("iceberg").mode("append").save(tableLocation); | ||
table.refresh(); | ||
|
||
Snapshot snapshot = table.currentSnapshot(); | ||
|
||
SparkActions actions = SparkActions.get(); | ||
|
@@ -431,6 +435,8 @@ public void testRewriteManifestsWithPredicate() throws IOException { | |
new ThreeColumnRecord(1, null, "AAAA"), new ThreeColumnRecord(1, "BBBBBBBBBB", "BBBB")); | ||
writeRecords(records1); | ||
|
||
writeRecords(records1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was a 1-to-1 no-op. So, added one more manifest to avoid no-op. |
||
|
||
List<ThreeColumnRecord> records2 = | ||
Lists.newArrayList( | ||
new ThreeColumnRecord(2, "CCCCCCCCCC", "CCCC"), | ||
|
@@ -440,21 +446,24 @@ public void testRewriteManifestsWithPredicate() throws IOException { | |
table.refresh(); | ||
|
||
List<ManifestFile> manifests = table.currentSnapshot().allManifests(table.io()); | ||
Assert.assertEquals("Should have 2 manifests before rewrite", 2, manifests.size()); | ||
Assert.assertEquals("Should have 3 manifests before rewrite", 3, manifests.size()); | ||
|
||
SparkActions actions = SparkActions.get(); | ||
|
||
// rewrite only the first manifest without caching | ||
RewriteManifests.Result result = | ||
actions | ||
.rewriteManifests(table) | ||
.rewriteIf(manifest -> manifest.path().equals(manifests.get(0).path())) | ||
.rewriteIf( | ||
manifest -> | ||
(manifest.path().equals(manifests.get(0).path()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. selecting more than one manifests for rewrite |
||
|| (manifest.path().equals(manifests.get(1).path())))) | ||
.stagingLocation(temp.newFolder().toString()) | ||
.option("use-caching", "false") | ||
.execute(); | ||
|
||
Assert.assertEquals( | ||
"Action should rewrite 1 manifest", 1, Iterables.size(result.rewrittenManifests())); | ||
"Action should rewrite 2 manifest", 2, Iterables.size(result.rewrittenManifests())); | ||
Assert.assertEquals( | ||
"Action should add 1 manifests", 1, Iterables.size(result.addedManifests())); | ||
|
||
|
@@ -464,11 +473,16 @@ public void testRewriteManifestsWithPredicate() throws IOException { | |
Assert.assertEquals("Should have 2 manifests after rewrite", 2, newManifests.size()); | ||
|
||
Assert.assertFalse("First manifest must be rewritten", newManifests.contains(manifests.get(0))); | ||
Assert.assertFalse( | ||
"Second manifest must be rewritten", newManifests.contains(manifests.get(1))); | ||
Assert.assertTrue( | ||
"Second manifest must not be rewritten", newManifests.contains(manifests.get(1))); | ||
"Third manifest must not be rewritten", newManifests.contains(manifests.get(2))); | ||
|
||
List<ThreeColumnRecord> expectedRecords = Lists.newArrayList(); | ||
expectedRecords.addAll(records1); | ||
expectedRecords.add(records1.get(0)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorted order insert |
||
expectedRecords.add(records1.get(0)); | ||
expectedRecords.add(records1.get(1)); | ||
expectedRecords.add(records1.get(1)); | ||
expectedRecords.addAll(records2); | ||
|
||
Dataset<Row> resultDF = spark.read().format("iceberg").load(tableLocation); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the result will be (1,1) without this PR.