[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:
@ -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
|
||||
|
||||
@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user