[Chore](materialized-view) forbid create mv have calculations included outside aggregate functions (#31336)

forbid create mv have calculations included outside aggregate functions
This commit is contained in:
Pxl
2024-02-26 11:23:04 +08:00
committed by yiguolei
parent b1fc0ebbe7
commit fcea2b964e
2 changed files with 20 additions and 0 deletions

View File

@ -288,6 +288,11 @@ public class CreateMaterializedViewStmt extends DdlStmt {
// build mv column item
mvColumnItemList.add(buildMVColumnItem(analyzer, functionCallExpr));
} else {
if (!isReplay && selectListItemExpr.containsAggregate()) {
throw new AnalysisException(
"The materialized view's expr calculations cannot be included outside aggregate functions"
+ ", expr: " + selectListItemExpr.toSql());
}
List<SlotRef> slots = new ArrayList<>();
selectListItemExpr.collect(SlotRef.class, slots);
if (!isReplay && slots.size() == 0) {