Skip to content

Commit

Permalink
[fix](planner)only forbid substitute literal expr in function call expr
Browse files Browse the repository at this point in the history
  • Loading branch information
starocean999 authored and morningman committed Aug 26, 2023
1 parent 153e8f0 commit 6a37d37
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,4 @@ public static int getParmLen(ByteBuffer data) {
public boolean matchExprs(List<Expr> exprs, SelectStmt stmt, boolean ignoreAlias, TupleDescriptor tuple) {
return true;
}

@Override
protected Expr substituteImpl(ExprSubstitutionMap smap, ExprSubstitutionMap disjunctsMap,
Analyzer analyzer) {
return this;
}
}

0 comments on commit 6a37d37

Please sign in to comment.