924060929 commented on code in PR #39801: URL: https://github.com/apache/doris/pull/39801#discussion_r1726999001
########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExpressionTrait.java: ########## @@ -79,23 +78,16 @@ default boolean foldable() { } /** - * Identify the expression is deterministic or not + * Identify the expression itself is deterministic or not, default true */ default boolean isDeterministic() { - boolean isDeterministic = true; - List<Expression> children = this.children(); - if (children.isEmpty()) { - return isDeterministic; - } - for (Expression child : children) { - Optional<ExpressionTrait> nonDeterministic = - child.collectFirst(expressionTreeNode -> expressionTreeNode instanceof ExpressionTrait - && !((ExpressionTrait) expressionTreeNode).isDeterministic()); - if (nonDeterministic.isPresent()) { - isDeterministic = false; - break; - } - } - return isDeterministic; + return true; + } + + /** + * Identify the expression is containing deterministic expr or not + */ + default boolean containsNondeterministic() { + return anyMatch(expr -> expr instanceof ExpressionTrait && !((ExpressionTrait) expr).isDeterministic()); Review Comment: remove `expr instanceof ExpressionTrait` ########## fe/fe-core/src/main/java/org/apache/doris/common/NereidsSqlCacheManager.java: ########## @@ -396,7 +396,8 @@ private boolean usedVariablesChanged(List<Variable> currentVariables, SqlCacheCo Variable currentVariable = currentVariables.get(i); Variable cachedVariable = cachedUsedVariables.get(i); if (!Objects.equals(currentVariable, cachedVariable) - || cachedVariable.getRealExpression().anyMatch(Nondeterministic.class::isInstance)) { + || cachedVariable.getRealExpression().anyMatch(expr -> expr instanceof ExpressionTrait + && !((ExpressionTrait) expr).isDeterministic())) { Review Comment: You can remove `expr instanceof ExpressionTrait` because Expression is always ExpressionTrait -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org