vikramahuja1001 commented on code in PR #5977: URL: https://github.com/apache/hive/pull/5977#discussion_r2215790537
########## ql/src/java/org/apache/hadoop/hive/ql/ddl/table/partition/PartitionUtils.java: ########## @@ -62,24 +62,33 @@ private PartitionUtils() { * simpler. Should be okay since the reserved names are fairly long and uncommon. */ public static void validatePartitions(HiveConf conf, Map<String, String> partitionSpec) throws SemanticException { - Set<String> reservedPartitionValues = new HashSet<>(); // Partition can't have this name - reservedPartitionValues.add(HiveConf.getVar(conf, ConfVars.DEFAULT_PARTITION_NAME)); - reservedPartitionValues.add(HiveConf.getVar(conf, ConfVars.DEFAULT_ZOOKEEPER_PARTITION_NAME)); + Set<String> reservedPartitionValues = + new HashSet<String>() {{ + add(HiveConf.getVar(conf, ConfVars.DEFAULT_PARTITION_NAME)); + add(HiveConf.getVar(conf, ConfVars.DEFAULT_ZOOKEEPER_PARTITION_NAME)); + }}; + // Partition value can't end in this suffix - reservedPartitionValues.add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_ORIGINAL)); - reservedPartitionValues.add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_ARCHIVED)); - reservedPartitionValues.add(HiveConf.getVar(conf, ConfVars.METASTORE_INT_EXTRACTED)); - - for (Entry<String, String> e : partitionSpec.entrySet()) { - for (String s : reservedPartitionValues) { - String value = e.getValue(); - if (value != null && value.contains(s)) { - throw new SemanticException(ErrorMsg.RESERVED_PART_VAL.getMsg( - "(User value: " + e.getValue() + " Reserved substring: " + s + ")")); - } + 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)); + }}; + + partitionSpec.forEach((key, value) -> { + if (value != null && reservedPartitionValues.contains(value)) { Review Comment: Thanks for the clarification @deniskuzZ , i will make the necessary changes and push. Don't you think it should be ` reservedPartitionValues.stream().filter(value::equals)` and not ` reservedPartitionValues.stream().filter(value::contains)`? For instance let's say my partition column is of type string and i have set Default partition name as 2012. Then even partitions like 2012-03-03 will not get added because of this. Let me know what you think? Currently i am pushing the code with ` reservedPartitionValues.stream().filter(value::equals)` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org