Skip to content
Merged
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
18 changes: 18 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,24 @@ public void analyze(Analyzer analyzer) throws UserException {
}
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ public TableSnapshot getTableSnapshot() {
return tableSnapshot;
}

public Boolean haveDesc() {
return desc != null;
}

/**
* This method should only be called after the TableRef has been analyzed.
*/
Expand Down