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

[SPARK-38521][SQL] Throw Exception if overwriting hive partition table with dynamic and staticPartitionOverwriteMode #35815

Conversation

jackylee-ch
Copy link
Contributor

Why are the changes needed?

The spark.sql.sources.partitionOverwriteMode allows us to overwrite the existing data of the table through staticmode, but for hive table, it is disastrous. It may deleting all data in hive partitioned table while writing with dynamic overwrite and partitionOverwriteMode=STATIC.
Here we add a check for this and throw Exception if this happends.

Does this PR introduce any user-facing change?

'No'.

How was this patch tested?

Add new ut

@github-actions github-actions bot added the SQL label Mar 11, 2022
@@ -234,7 +237,7 @@ case class InsertIntoHadoopFsRelationCommand(
if (fs.exists(staticPrefixPath) && !committer.deleteWithJob(fs, staticPrefixPath, true)) {
throw QueryExecutionErrors.cannotClearOutputDirectoryError(staticPrefixPath)
}
// now clear all custom partition locations (e.g. /custom/dir/where/foo=2/bar=4)
// now clear custom static partition locations (e.g. /custom/dir/where/foo=1)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changed because after this PR, only overwriting the static partition will run into deleteMatchingPartitions.

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants