saihemanth-cloudera commented on code in PR #5141:
URL: https://github.com/apache/hive/pull/5141#discussion_r1542089503
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java:
##########
@@ -1525,30 +1527,33 @@ public void visit(LeafNode node) throws MetaException {
if (isOpEquals || Operator.isNotEqualOperator(node.operator)) {
Map<String, String> partKeyToVal = new HashMap<>();
partKeyToVal.put(partCol.getName(), node.value.toString());
- String escapedNameFragment = Warehouse.makePartName(partKeyToVal,
false);
+ String escapedNameFragmentPart = Warehouse.makePartName(partKeyToVal,
false);
if (colType == FilterType.Date) {
// Some engines like Pig will record both date and time values, in
which case we need
// match PART_NAME by like clause.
- escapedNameFragment += "%";
+ escapedNameFragmentPart += "%";
}
+ StringBuilder sbFilter = new StringBuilder();
+ for (int i = 0; i < partitionKeys.size(); i++) {
+ FieldSchema col = partitionKeys.get(i);
+ if (i > 0) {
+ sbFilter.append(Path.SEPARATOR);
+ }
+ if (partCol.getName().equals(col.getName())) {
+ sbFilter.append(escapedNameFragmentPart);
+ } else {
+
sbFilter.append(FileUtils.escapePathName(col.getName().toLowerCase(), "_%"));
+ sbFilter.append('=');
+ sbFilter.append(FileUtils.escapePathName(null, "_%"));
+ }
+ }
+ String escapedNameFragment = sbFilter.toString();
if (colType != FilterType.Date && partColCount == 1) {
// Case where partition column type is not date and there is no
other partition columns
params.add(escapedNameFragment);
filter += " and " + PARTITIONS + ".\"PART_NAME\"" + (isOpEquals ? "
=? " : " !=? ");
} else {
- if (partColCount == 1) {
- // Case where partition column type is date and there is no other
partition columns
- params.add(escapedNameFragment);
- } else if (partColIndex + 1 == partColCount) {
- // Case where the partition column is at the end of the name.
- params.add("%/" + escapedNameFragment);
- } else if (partColIndex == 0) {
- // Case where the partition column is at the beginning of the name.
- params.add(escapedNameFragment + "/%");
- } else {
- // Case where the partition column is in the middle of the name.
- params.add("%/" + escapedNameFragment + "/%");
- }
+ params.add(escapedNameFragment);
filter += " and " + PARTITIONS + ".\"PART_NAME\"" + (isOpEquals ? "
like ? " : " not like ? ");
Review Comment:
Can you add a test case to verify that this is working?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]