Skip to content

Commit 3cbbf2c

Browse files
committed
fix ordering
1 parent 2c414ae commit 3cbbf2c

File tree

1 file changed

+6
-7
lines changed
  • standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore

1 file changed

+6
-7
lines changed

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3811,7 +3811,7 @@ protected Integer getJdoResult(GetHelper<Integer> ctx)
38113811
* you want results for. E.g., if resultsCol is partitionName, the Collection
38123812
* has types of String, and if resultsCol is null, the types are MPartition.
38133813
*/
3814-
private Collection<String> getPartitionPsQueryResults(String catName, String dbName,
3814+
private <T> Collection<T> getPartitionPsQueryResults(String catName, String dbName,
38153815
String tableName, List<String> part_vals,
38163816
int max_parts, String resultsCol)
38173817
throws MetaException, NoSuchObjectException {
@@ -3831,6 +3831,7 @@ private Collection<String> getPartitionPsQueryResults(String catName, String dbN
38313831
String filter = getJDOFilterStrForPartitionVals(table, part_vals, params);
38323832
try (QueryWrapper query = new QueryWrapper(pm.newQuery(MPartition.class))) {
38333833
query.setFilter(filter);
3834+
query.setOrdering("partitionName ascending");
38343835
query.declareParameters(makeParameterDeclarationString(params));
38353836
if (max_parts >= 0) {
38363837
// User specified a row limit, set it on the Query
@@ -3839,9 +3840,7 @@ private Collection<String> getPartitionPsQueryResults(String catName, String dbN
38393840
if (resultsCol != null && !resultsCol.isEmpty()) {
38403841
query.setResult(resultsCol);
38413842
}
3842-
3843-
Collection<String> result = (Collection<String>) query.executeWithMap(params);
3844-
3843+
Collection<T> result = (Collection<T>) query.executeWithMap(params);
38453844
return Collections.unmodifiableCollection(new ArrayList<>(result));
38463845
}
38473846
}
@@ -3912,11 +3911,11 @@ protected List<Partition> getSqlResult(GetHelper<List<Partition>> ctx) throws Me
39123911
protected List<Partition> getJdoResult(GetHelper<List<Partition>> ctx)
39133912
throws MetaException, NoSuchObjectException {
39143913
List<Partition> result = new ArrayList<>();
3915-
Collection parts = getPartitionPsQueryResults(catName, dbName, tblName,
3914+
Collection<MPartition> parts = getPartitionPsQueryResults(catName, dbName, tblName,
39163915
args.getPart_vals(), args.getMax(), null);
39173916
boolean isAcidTable = TxnUtils.isAcidTable(ctx.getTable());
3918-
for (Object o : parts) {
3919-
Partition part = convertToPart(catName, dbName, tblName, (MPartition) o, isAcidTable, args);
3917+
for (MPartition o : parts) {
3918+
Partition part = convertToPart(catName, dbName, tblName, o, isAcidTable, args);
39203919
result.add(part);
39213920
}
39223921
return result;

0 commit comments

Comments
 (0)