Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.doris.nereids.trees.plans.algebra.Filter;
import org.apache.doris.nereids.trees.plans.algebra.Generate;
import org.apache.doris.nereids.trees.plans.algebra.Limit;
import org.apache.doris.nereids.trees.plans.algebra.OlapScan;
import org.apache.doris.nereids.trees.plans.algebra.PartitionTopN;
import org.apache.doris.nereids.trees.plans.algebra.Project;
import org.apache.doris.nereids.trees.plans.algebra.Repeat;
Expand Down Expand Up @@ -608,7 +609,7 @@ private Statistics computeFilter(Filter filter) {
return new FilterEstimation().estimate(filter.getPredicate(), stats);
}

private ColumnStatistic getColumnStatistic(TableIf table, String colName) {
private ColumnStatistic getColumnStatistic(TableIf table, String colName, long idxId) {
ConnectContext connectContext = ConnectContext.get();
if (connectContext != null && connectContext.getSessionVariable().internalSession) {
return ColumnStatistic.UNKNOWN;
Expand All @@ -633,9 +634,8 @@ private ColumnStatistic getColumnStatistic(TableIf table, String colName) {
return ColumnStatistic.UNKNOWN;
}
} else {
// TODO. Get index id for materialized view.
return Env.getCurrentEnv().getStatisticsCache().getColumnStatistics(
catalogId, dbId, table.getId(), -1, colName);
catalogId, dbId, table.getId(), idxId, colName);
}
}

Expand All @@ -649,6 +649,11 @@ private Statistics computeCatalogRelation(CatalogRelation catalogRelation) {
TableIf table = catalogRelation.getTable();
double rowCount = catalogRelation.getTable().estimatedRowCount();
boolean hasUnknownCol = false;
long idxId = -1;
if (catalogRelation instanceof OlapScan) {
OlapScan olapScan = (OlapScan) catalogRelation;
idxId = olapScan.getSelectedIndexId();
}
for (SlotReference slotReference : slotSet) {
String colName = slotReference.getName();
boolean shouldIgnoreThisCol = StatisticConstants.shouldIgnoreCol(table, slotReference.getColumn().get());
Expand All @@ -661,7 +666,7 @@ private Statistics computeCatalogRelation(CatalogRelation catalogRelation) {
|| shouldIgnoreThisCol) {
cache = ColumnStatistic.UNKNOWN;
} else {
cache = getColumnStatistic(table, colName);
cache = getColumnStatistic(table, colName, idxId);
}
if (cache.avgSizeByte <= 0) {
cache = new ColumnStatisticBuilder(cache)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.doris.catalog.Table;
import org.apache.doris.nereids.memo.GroupExpression;
import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.rules.rewrite.mv.AbstractSelectMaterializedIndexRule;
// import org.apache.doris.nereids.rules.rewrite.mv.AbstractSelectMaterializedIndexRule;
import org.apache.doris.nereids.trees.TableSample;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.expressions.SlotReference;
Expand Down Expand Up @@ -369,9 +369,10 @@ public List<Slot> getOutputByIndex(long indexId) {
}

private Slot generateUniqueSlot(OlapTable table, Column column, boolean isBaseIndex, long indexId) {
String name = isBaseIndex || directMvScan ? column.getName()
: AbstractSelectMaterializedIndexRule.parseMvColumnToMvName(column.getName(),
column.isAggregated() ? Optional.of(column.getAggregationType().toSql()) : Optional.empty());
String name = column.getName();
// String name = isBaseIndex || directMvScan ? column.getName()
// : AbstractSelectMaterializedIndexRule.parseMvColumnToMvName(column.getName(),
// column.isAggregated() ? Optional.of(column.getAggregationType().toSql()) : Optional.empty());
if (cacheSlotWithSlotName.containsKey(Pair.of(indexId, name))) {
return cacheSlotWithSlotName.get(Pair.of(indexId, name));
}
Expand Down