[Improvement](materialized-view) forbidden mv rewriter when select stmt's from clause not have mv (#27638)

forbidden mv rewriter when select stmt's from clause not have mv
This commit is contained in:
Pxl
2023-11-28 14:11:46 +08:00
committed by GitHub
parent f565f60bc3
commit 31fe48111b
2 changed files with 22 additions and 0 deletions

View File

@ -503,6 +503,24 @@ public class SelectStmt extends QueryStmt {
}
fromClause.setNeedToSql(needToSql);
fromClause.analyze(analyzer);
if (!isForbiddenMVRewrite()) {
Boolean haveMv = false;
for (TableRef tbl : fromClause) {
if (!tbl.haveDesc() || !(tbl.getTable() instanceof OlapTable)) {
continue;
}
OlapTable olapTable = (OlapTable) tbl.getTable();
if (olapTable.getIndexIds().size() != 1) {
haveMv = true;
}
}
if (!haveMv) {
forbiddenMVRewrite();
}
}
// Generate !empty() predicates to filter out empty collections.
// Skip this step when analyzing a WITH-clause because CollectionTableRefs
// do not register collection slots in their parent in that context

View File

@ -329,6 +329,10 @@ public class TableRef implements ParseNode, Writable {
return tableSnapshot;
}
public Boolean haveDesc() {
return desc != null;
}
/**
* This method should only be called after the TableRef has been analyzed.
*/