Skip to content
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

Uniform iceberg conversion transaction should not convert commit with only AddFiles without datachange - 3.1 #3619

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ class IcebergConverter(spark: SparkSession)
var hasRemoves = false
var hasDataChange = false
var hasCommitInfo = false
var commitInfo: Option[CommitInfo] = None
breakable {
for (action <- actionsToCommit) {
action match {
Expand All @@ -370,7 +371,9 @@ class IcebergConverter(spark: SparkSession)
case r: RemoveFile =>
hasRemoves = true
if (r.dataChange) hasDataChange = true
case _: CommitInfo => hasCommitInfo = true
case ci: CommitInfo =>
commitInfo = Some(ci)
hasCommitInfo = true
case _ => // Do nothing
}
if (hasAdds && hasRemoves && hasDataChange && hasCommitInfo) break // Short-circuit
Expand Down Expand Up @@ -404,9 +407,14 @@ class IcebergConverter(spark: SparkSession)
}
overwriteHelper.commit()
} else if (hasAdds) {
val appendHelper = icebergTxn.getAppendOnlyHelper()
addsAndRemoves.foreach(action => appendHelper.add(action.add))
appendHelper.commit()
if (!hasRemoves && !hasDataChange && allDeltaActionsCaptured) {
logInfo(s"Skip Iceberg conversion for commit that only has AddFiles " +
s"without any RemoveFiles or data change. CommitInfo: $commitInfo")
} else {
val appendHelper = icebergTxn.getAppendOnlyHelper()
addsAndRemoves.foreach(action => appendHelper.add(action.add))
appendHelper.commit()
}
} else if (hasRemoves) {
val removeHelper = icebergTxn.getRemoveOnlyHelper()
addsAndRemoves.foreach(action => removeHelper.remove(action.remove))
Expand Down
Loading