Skip to content

Commit 86cc5a9

Browse files
committed
sync mv don't support unnest
1 parent b3e496b commit 86cc5a9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.apache.doris.nereids.trees.expressions.functions.agg.Min;
6868
import org.apache.doris.nereids.trees.expressions.functions.agg.Sum;
6969
import org.apache.doris.nereids.trees.expressions.functions.combinator.StateCombinator;
70+
import org.apache.doris.nereids.trees.expressions.functions.generator.Unnest;
7071
import org.apache.doris.nereids.trees.expressions.functions.scalar.ToBitmap;
7172
import org.apache.doris.nereids.trees.expressions.functions.scalar.ToBitmapWithCheck;
7273
import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral;
@@ -299,7 +300,7 @@ public Plan visitLogicalFilter(LogicalFilter<? extends Plan> filter, ValidateCon
299300
throw new AnalysisException(
300301
String.format("Only support one filter node, the second is %s", filter.getPredicate()));
301302
}
302-
checkNoNondeterministicFunction(filter);
303+
checkNoNondeterministicFunctionOrUnnest(filter);
303304
Set<Expression> conjuncts = filter.getConjuncts().stream().filter(expr -> {
304305
Set<Slot> slots = expr.getInputSlots();
305306
for (Slot slot : slots) {
@@ -343,7 +344,7 @@ public Plan visitLogicalAggregate(LogicalAggregate<? extends Plan> aggregate, Va
343344
throw new AnalysisException(String.format("Only support one agg node, the second is %s", aggregate));
344345
}
345346
context.keysType = KeysType.AGG_KEYS;
346-
checkNoNondeterministicFunction(aggregate);
347+
checkNoNondeterministicFunctionOrUnnest(aggregate);
347348
for (AggregateFunction aggregateFunction : aggregate.getAggregateFunctions()) {
348349
validateAggFunnction(aggregateFunction);
349350
}
@@ -369,7 +370,7 @@ public Plan visitLogicalSort(LogicalSort<? extends Plan> sort, ValidateContext c
369370
if (context.orderByExprs != null) {
370371
throw new AnalysisException(String.format("Only support one sort node, the second is %s", sort));
371372
}
372-
checkNoNondeterministicFunction(sort);
373+
checkNoNondeterministicFunctionOrUnnest(sort);
373374
if (sort.getOrderKeys().stream().anyMatch((
374375
orderKey -> orderKey.getExpr().getDataType().isObjectOrVariantType()))) {
375376
throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
@@ -390,7 +391,7 @@ public Plan visitLogicalSort(LogicalSort<? extends Plan> sort, ValidateContext c
390391
@Override
391392
public Plan visitLogicalProject(LogicalProject<? extends Plan> project, ValidateContext context) {
392393
super.visit(project, context);
393-
checkNoNondeterministicFunction(project);
394+
checkNoNondeterministicFunctionOrUnnest(project);
394395
List<NamedExpression> outputs = project.getOutputs();
395396
if (!context.exprReplaceMap.isEmpty()) {
396397
outputs = ExpressionUtils.replaceNamedExpressions(outputs, context.exprReplaceMap);
@@ -642,14 +643,15 @@ private Expression getAggFunctionFirstParam(AggregateFunction aggregateFunction)
642643
return aggregateFunction.child(0);
643644
}
644645

645-
private void checkNoNondeterministicFunction(Plan plan) {
646+
private void checkNoNondeterministicFunctionOrUnnest(Plan plan) {
646647
for (Expression expression : plan.getExpressions()) {
647-
Set<Expression> nondeterministicFunctions = expression
648-
.collect(expr -> !((ExpressionTrait) expr).isDeterministic()
649-
&& expr instanceof FunctionTrait);
650-
if (!nondeterministicFunctions.isEmpty()) {
648+
Set<Expression> unsupportedFunctions = expression
649+
.collect(expr -> expr instanceof Unnest || (!((ExpressionTrait) expr).isDeterministic()
650+
&& expr instanceof FunctionTrait));
651+
if (!unsupportedFunctions.isEmpty()) {
651652
throw new AnalysisException(String.format(
652-
"can not contain nonDeterministic expression, the expression is %s ", expression));
653+
"can not contain nonDeterministic expression or unnest, the expression is %s ",
654+
expression));
653655
}
654656
}
655657
}

0 commit comments

Comments
 (0)