cxzl25 commented on code in PR #5141:
URL: https://github.com/apache/hive/pull/5141#discussion_r1547103914
##########
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 paste your benchmark test result
```bash
java -jar ./hmsbench.jar -H localhost --savedata /tmp/benchdata --sanitize
-N 10 -N 1000 -N 10000 -d testbench_http -M 'getPartitionsByFilter.*'
--runMode NONACID
```
master
```
Operation Mean Med Min Max Err%
getPartitionsByFilter 1.992 1.526 1.221 5.882 49.42
getPartitionsByFilter.10 1.343 1.302 1.168 3.491 17.86
getPartitionsByFilter.1000 3.091 3.000 2.763 5.455 12.20
getPartitionsByFilter.10000 3.221 3.058 2.789 6.958 18.99
```
PR
```
Operation Mean Med Min Max Err%
getPartitionsByFilter 1.405 1.296 1.147 3.267 22.57
getPartitionsByFilter.10 1.229 1.189 1.080 3.019 16.26
getPartitionsByFilter.1000 2.937 2.858 2.669 5.533 12.52
getPartitionsByFilter.10000 3.091 3.024 2.774 5.182 11.30
```
--
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]