-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29093 : Fix alter table add partition if DEFAULT_PARTITION_NAME propery is a substring of partitition value to be added #5977
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: master
Are you sure you want to change the base?
Conversation
…g of partition value.
reservedPartitionValues.add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_EXTRACTED)); | ||
reservedSuffixPartitionValues.add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_ORIGINAL)); | ||
reservedSuffixPartitionValues.add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_ARCHIVED)); | ||
reservedSuffixPartitionValues.add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_EXTRACTED)); | ||
|
||
for (Entry<String, String> e : partitionSpec.entrySet()) { |
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.
could we please refactor with
partitionSpec.foreach((key, value) -> {
if (value != null && reservedPartitionValue.containsKey(value)) {
...
}
}
similar for reservedPartitionSuffixes
@@ -63,20 +63,28 @@ private PartitionUtils() { | |||
*/ | |||
public static void validatePartitions(HiveConf conf, Map<String, String> partitionSpec) throws SemanticException { | |||
Set<String> reservedPartitionValues = new HashSet<>(); | |||
Set<String> reservedSuffixPartitionValues = new HashSet<>(); |
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.
maybe reservedPartitionSuffixes
? also why not do anonymous initialization?
Set<String> reservedPartitionSuffixes =
new HashSet<String>() {{
add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_ORIGINAL));
add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_ARCHIVED));
add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_EXTRACTED));
}};
a48cc2b
to
4d6b6e1
Compare
}}; | ||
|
||
partitionSpec.forEach((key, value) -> { | ||
if (value != null && reservedPartitionValues.contains(value)) { |
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.
sorry, my bad
partitionSpec.forEach((key, value) -> {
if (value == null) {
return;
}
reservedPartitionValues.stream().filter(value::contains).findAny()
.ifPresent(s -> {
throw new RuntimeException(ErrorMsg.RESERVED_PART_VAL.getMsg(
"(User value: " + value + " Reserved string: " + s + ")"));
});
reservedPartitionSuffixes.stream().filter(value::endsWith)
.ifPresent(s -> {
throw new RuntimeException(ErrorMsg.RESERVED_PART_VAL.getMsg(
"(User value: " + value + " Partition value cannot end with Reserved substring: " + s + ")"));
});
});
|
…g of partition value.
What changes were proposed in this pull request?
Why are the changes needed?
Does this PR introduce any user-facing change?
How was this patch tested?