-
Notifications
You must be signed in to change notification settings - Fork 265
feat: Support dynamic partition overwrite mode in comet #3005
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
base: main
Are you sure you want to change the base?
Conversation
|
@comphead this is the PR to support overwrite mode in comet. Please take a look whenever you get a chance |
comphead
left a comment
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.
Thanks @coderfender I think it would be also needed to support partititioned mode. Otherwise this approach will delete entire user data
The flow is like
User calls: df.write.mode("overwrite").save(path)
↓
DataFrameWriter.saveInternal()
↓
InsertIntoHadoopFsRelationCommand.run()
↓
[Line 131] deleteMatchingPartitions(fs, qualifiedOutputPath, customPartitionLocations, committer)
↓
[Line 238] committer.deleteWithJob(fs, staticPrefixPath, true)
↓
[Line 183] fs.delete(path, recursive=true) ← ACTUAL DELETION HAPPENS HERE
This Spark implementation now
val doInsertion = if (mode == SaveMode.Append) {
true
} else {
val pathExists = fs.exists(qualifiedOutputPath)
(mode, pathExists) match {
case (SaveMode.ErrorIfExists, true) =>
throw QueryCompilationErrors.outputPathAlreadyExistsError(qualifiedOutputPath)
case (SaveMode.Overwrite, true) =>
if (ifPartitionNotExists && matchingPartitions.nonEmpty) {
false
} else if (dynamicPartitionOverwrite) {
// For dynamic partition overwrite, do not delete partition directories ahead.
true
} else {
deleteMatchingPartitions(fs, qualifiedOutputPath, customPartitionLocations, committer)
true
}
case (SaveMode.Overwrite, _) | (SaveMode.ErrorIfExists, false) =>
true
case (SaveMode.Ignore, exists) =>
!exists
case (s, exists) =>
throw QueryExecutionErrors.saveModeUnsupportedError(s, exists)
}
}
|
Thank you @comphead . Let me work on updating the code to not delete entire user data and just clear out the effected partitions |
Thanks @coderfender Ideally if we can reuse Spark code |
|
Sure .Thank you. Let me try and port spark code to not have duplication |
Which issue does this PR close?
Closes ##2970
Rationale for this change
What changes are included in this PR?
How are these changes tested?