[fix](Nereids) Disable preagg when there is DELETE_SIGN filter (#17157)

1. disable preAgg when there is delete sign when binding relation
2. keep the preAgg status in SelectMaterializeIndex rule
This commit is contained in:
谢健
2023-02-28 19:59:05 +08:00
committed by GitHub
parent 1ced23018e
commit 94cea0ea6d
5 changed files with 99 additions and 0 deletions

View File

@ -44,6 +44,7 @@ import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.PreAggStatus;
import org.apache.doris.nereids.trees.plans.logical.LogicalFileScan;
import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
import org.apache.doris.nereids.trees.plans.logical.LogicalJdbcScan;
@ -194,6 +195,10 @@ public class BindRelation extends OneAnalysisRuleFactory {
}
Preconditions.checkArgument(deleteSlot != null);
Expression conjunct = new EqualTo(new TinyIntLiteral((byte) 0), deleteSlot);
if (!((OlapTable) table).getEnableUniqueKeyMergeOnWrite()) {
scan = scan.withPreAggStatus(PreAggStatus.off(
Column.DELETE_SIGN + " is used as conjuncts."));
}
return new LogicalFilter(Sets.newHashSet(conjunct), scan);
}
return scan;

View File

@ -549,6 +549,10 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
return new SelectResult(PreAggStatus.on(), selectIndexId,
rewriteResultOpt.map(r -> r.exprRewriteMap).orElse(new ExprRewriteMap()));
} else {
if (scan.getPreAggStatus().isOff()) {
return new SelectResult(scan.getPreAggStatus(),
scan.getTable().getBaseIndexId(), new ExprRewriteMap());
}
final PreAggStatus preAggStatus;
if (preAggEnabledByHint(scan)) {
// PreAggStatus could be enabled by pre-aggregation hint for agg-keys and unique-keys.

View File

@ -246,6 +246,12 @@ public class LogicalOlapScan extends LogicalRelation implements CatalogRelation,
selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, hints);
}
public LogicalOlapScan withPreAggStatus(PreAggStatus preAggStatus) {
return new LogicalOlapScan(id, (Table) table, qualifier, Optional.empty(), Optional.of(getLogicalProperties()),
selectedPartitionIds, partitionPruned, selectedTabletIds, true,
selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, hints);
}
@Override
public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
return visitor.visitLogicalOlapScan(this, context);