Skip to content

Commit

Permalink
Revert "53787 53881"
Browse files Browse the repository at this point in the history
  • Loading branch information
andyziye committed Dec 25, 2024
1 parent 76526c0 commit d02c72f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,6 @@ public Map<Long, List<String>> getIdToValues() {
return idToValues;
}

public boolean isSingleValuePartition(long id) {
List<String> values = getIdToValues().get(id);
if (values != null && values.size() == 1) {
return true;
}
List<List<String>> multiValues = getIdToMultiValues().get(id);
if (multiValues != null && multiValues.size() == 1) {
return true;
}
return false;
}

/**
* serialize data to log
*
Expand Down
4 changes: 3 additions & 1 deletion fe/fe-core/src/main/java/com/starrocks/qe/Coordinator.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public class Coordinator {
private final boolean isBlockQuery;
private int numReceivedRows = 0;
private List<String> deltaUrls;
private final Map<String, String> loadCounters = new HashMap<>();
private Map<String, String> loadCounters;
private String trackingUrl;
private final Set<String> rejectedRecordPaths = new HashSet<>();
// for export
Expand Down Expand Up @@ -246,6 +246,7 @@ public Coordinator(StreamLoadPlanner planner, TNetworkAddress address) {
attachInstanceProfileToFragmentProfile();

deltaUrls = Lists.newArrayList();
loadCounters = Maps.newHashMap();
this.connectContext = planner.getConnectContext();

// for complie
Expand Down Expand Up @@ -714,6 +715,7 @@ private void prepareResultSink() throws Exception {
queryOptions.setRuntime_profile_report_interval(30);
}
deltaUrls = Lists.newArrayList();
loadCounters = Maps.newHashMap();
List<Long> relatedBackendIds = Lists.newArrayList(coordinatorPreprocessor.getAddressToBackendID().values());
GlobalStateMgr.getCurrentState().getLoadMgr()
.initJobProgress(jobId, queryId, coordinatorPreprocessor.getInstanceIds(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private static List<Long> listPartitionPrune(OlapTable olapTable, ListPartitionI

List<ScalarOperator> scalarOperatorList = Utils.extractConjuncts(operator.getPredicate());
PartitionPruner partitionPruner = new ListPartitionPruner(columnToPartitionValuesMap,
columnToNullPartitions, scalarOperatorList, specifyPartitionIds, listPartitionInfo);
columnToNullPartitions, scalarOperatorList, specifyPartitionIds);
try {
List<Long> prune = partitionPruner.prune();
if (prune == null && isTemporaryPartitionPrune) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.starrocks.analysis.BinaryType;
import com.starrocks.analysis.Expr;
import com.starrocks.analysis.LiteralExpr;
import com.starrocks.catalog.ListPartitionInfo;
import com.starrocks.catalog.Type;
import com.starrocks.common.AnalysisException;
import com.starrocks.common.Pair;
Expand Down Expand Up @@ -84,27 +83,17 @@ public class ListPartitionPruner implements PartitionPruner {
private final Set<Long> allPartitions;
private final List<ColumnRefOperator> partitionColumnRefs;
private final List<Long> specifyPartitionIds;
private final ListPartitionInfo listPartitionInfo;

public ListPartitionPruner(
Map<ColumnRefOperator, ConcurrentNavigableMap<LiteralExpr, Set<Long>>> columnToPartitionValuesMap,
Map<ColumnRefOperator, Set<Long>> columnToNullPartitions,
List<ScalarOperator> partitionConjuncts, List<Long> specifyPartitionIds) {
this(columnToPartitionValuesMap, columnToNullPartitions, partitionConjuncts, specifyPartitionIds, null);
}

public ListPartitionPruner(
Map<ColumnRefOperator, ConcurrentNavigableMap<LiteralExpr, Set<Long>>> columnToPartitionValuesMap,
Map<ColumnRefOperator, Set<Long>> columnToNullPartitions,
List<ScalarOperator> partitionConjuncts, List<Long> specifyPartitionIds,
ListPartitionInfo listPartitionInfo) {
this.columnToPartitionValuesMap = columnToPartitionValuesMap;
this.columnToNullPartitions = columnToNullPartitions;
this.partitionConjuncts = partitionConjuncts;
this.allPartitions = getAllPartitions();
this.partitionColumnRefs = getPartitionColumnRefs();
this.specifyPartitionIds = specifyPartitionIds;
this.listPartitionInfo = listPartitionInfo;
}

private Set<Long> getAllPartitions() {
Expand Down Expand Up @@ -346,17 +335,7 @@ private Set<Long> evalBinaryPredicate(BinaryPredicateOperator binaryPredicate) {
matches.removeAll(nullPartitions);
// remove partition matches literal
if (partitionValueMap.containsKey(literal)) {
if (listPartitionInfo == null) {
// external table
matches.removeAll(partitionValueMap.get(literal));
} else {
Set<Long> partitionIds = partitionValueMap.get(literal);
for (Long id : partitionIds) {
if (listPartitionInfo.isSingleValuePartition(id)) {
matches.remove(id);
}
}
}
matches.removeAll(partitionValueMap.get(literal));
}
return matches;
case LE:
Expand Down Expand Up @@ -469,18 +448,7 @@ private Set<Long> evalInPredicate(InPredicateOperator inPredicate) {
Set<Long> partitions = partitionValueMap.get(literal);
if (partitions != null) {
if (inPredicate.isNotIn()) {
// external table, one partition column for one partition can only have one value
if (listPartitionInfo == null) {
matches.removeAll(partitions);
} else {
// for olap table, if one partition is multi value partition like PARTITION pCalifornia VALUES IN ("Los Angeles","San Francisco","San Diego")
// and we have a not in predicate like city not in ("Los Angeles"), it's not safe to remove this partition
for (Long id : partitions) {
if (listPartitionInfo.isSingleValuePartition(id)) {
matches.remove(id);
}
}
}
matches.removeAll(partitions);
} else {
matches.addAll(partitions);
}
Expand Down

0 comments on commit d02c72f

Please sign in to comment.