[BUG] Make default result ordering of SHOW PARTITIONS statement be consist with 0.11 (#3184)

This commit is contained in:
Dayue Gao
2020-03-24 17:14:27 +08:00
committed by GitHub
parent e20d905d70
commit e794bb69b7
3 changed files with 15 additions and 14 deletions

View File

@ -1444,10 +1444,6 @@ public class OlapTable extends Table {
tempPartitions.dropAll();
}
public Collection<Partition> getAllTempPartitions() {
return tempPartitions.getAllPartitions();
}
public boolean existTempPartitions() {
return !tempPartitions.isEmpty();
}

View File

@ -51,10 +51,10 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@ -209,18 +209,23 @@ public class PartitionsProcDir implements ProcDirInterface {
List<List<Comparable>> partitionInfos = new ArrayList<List<Comparable>>();
db.readLock();
try {
Set<String> partitionsNames;
if (isTempPartition) {
partitionsNames = olapTable.getAllTempPartitions().stream().map(p -> p.getName()).collect(Collectors.toSet());
List<Long> partitionIds;
PartitionInfo tblPartitionInfo = olapTable.getPartitionInfo();
// for range partitions, we return partitions in ascending range order by default.
// this is to be consistent with the behaviour before 0.12
if (tblPartitionInfo.getType() == PartitionType.RANGE) {
RangePartitionInfo rangePartitionInfo = (RangePartitionInfo) tblPartitionInfo;
partitionIds = rangePartitionInfo.getSortedRangeMap(isTempPartition).stream()
.map(Map.Entry::getKey).collect(Collectors.toList());
} else {
partitionsNames = olapTable.getPartitions().stream().map(p -> p.getName()).collect(Collectors.toSet());
Collection<Partition> partitions = isTempPartition ? olapTable.getTempPartitions() : olapTable.getPartitions();
partitionIds = partitions.stream().map(Partition::getId).collect(Collectors.toList());
}
Joiner joiner = Joiner.on(", ");
PartitionInfo tblPartitionInfo = olapTable.getPartitionInfo();
for (String partName : partitionsNames) {
Partition partition = olapTable.getPartition(partName, isTempPartition);
long partitionId = partition.getId();
for (Long partitionId : partitionIds) {
Partition partition = olapTable.getPartition(partitionId);
List<Comparable> partitionInfo = new ArrayList<Comparable>();
String partitionName = partition.getName();

View File

@ -578,7 +578,7 @@ public class TempPartitionTest {
OlapTable readTbl = (OlapTable) Table.read(in);
Assert.assertEquals(tbl.getId(), readTbl.getId());
Assert.assertEquals(tbl.getAllTempPartitions().size(), readTbl.getAllTempPartitions().size());
Assert.assertEquals(tbl.getTempPartitions().size(), readTbl.getTempPartitions().size());
file.delete();
}