diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java index 9abd91acad7c261..17112e1f03deaf8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java @@ -478,7 +478,30 @@ protected Expr substituteImpl(ExprSubstitutionMap smap, ExprSubstitutionMap disj aggFnParams = aggFnParams .clone(newParams); } - return super.substituteImpl(smap, disjunctsMap, analyzer); + if (isImplicitCast()) { + return getChild(0).substituteImpl(smap, disjunctsMap, analyzer); + } + if (smap != null) { + Expr substExpr = smap.get(this); + if (substExpr != null) { + return substExpr.clone(); + } + } + if (Expr.IS_OR_PREDICATE.apply(this) && disjunctsMap != null) { + smap = disjunctsMap; + disjunctsMap = null; + } + for (int i = 0; i < children.size(); ++i) { + // we shouldn't change literal expr in function call expr + if (!(children.get(i) instanceof LiteralExpr)) { + children.set(i, children.get(i).substituteImpl(smap, disjunctsMap, analyzer)); + } + } + // SlotRefs must remain analyzed to support substitution across query blocks. All + // other exprs must be analyzed again after the substitution to add implicit casts + // and for resolving their correct function signature. + resetAnalysisState(); + return this; } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java index 2e2eed316b25862..bde041aeefa73e0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java @@ -402,10 +402,4 @@ public static int getParmLen(ByteBuffer data) { public boolean matchExprs(List exprs, SelectStmt stmt, boolean ignoreAlias, TupleDescriptor tuple) { return true; } - - @Override - protected Expr substituteImpl(ExprSubstitutionMap smap, ExprSubstitutionMap disjunctsMap, - Analyzer analyzer) { - return this; - } }