[Bug](insert) try to fix invalid slot when insert (#30570)

try to fix invalid slot when insert
This commit is contained in:
Pxl
2024-02-01 10:39:02 +08:00
committed by yiguolei
parent 1f754c55d5
commit 8d906c48e8
5 changed files with 22 additions and 13 deletions

View File

@ -1542,6 +1542,7 @@ public abstract class Expr extends TreeNode<Expr> implements ParseNode, Cloneabl
if (this.type.isAggStateType()) {
List<Type> subTypes = ((AggStateType) targetType).getSubTypes();
List<Boolean> subNullables = ((AggStateType) targetType).getSubTypeNullables();
if (this instanceof FunctionCallExpr) {
if (subTypes.size() != getChildren().size()) {
@ -1549,6 +1550,16 @@ public abstract class Expr extends TreeNode<Expr> implements ParseNode, Cloneabl
}
for (int i = 0; i < subTypes.size(); i++) {
setChild(i, getChild(i).castTo(subTypes.get(i)));
if (getChild(i).isNullable() && !subNullables.get(i)) {
FunctionCallExpr newChild = new FunctionCallExpr("non_nullable",
Lists.newArrayList(getChild(i)));
newChild.analyzeImplForDefaultValue(subTypes.get(i));
setChild(i, newChild);
} else if (!getChild(i).isNullable() && subNullables.get(i)) {
FunctionCallExpr newChild = new FunctionCallExpr("nullable", Lists.newArrayList(getChild(i)));
newChild.analyzeImplForDefaultValue(subTypes.get(i));
setChild(i, newChild);
}
}
type = targetType;
} else {

View File

@ -1361,8 +1361,12 @@ public class FunctionCallExpr extends Expr {
* @throws AnalysisException
*/
public void analyzeImplForDefaultValue(Type type) throws AnalysisException {
fn = new Function(getBuiltinFunction(fnName.getFunction(), new Type[0],
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF));
Type[] childTypes = new Type[children.size()];
for (int i = 0; i < children.size(); i++) {
childTypes[i] = children.get(i).type;
}
fn = new Function(
getBuiltinFunction(fnName.getFunction(), childTypes, Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF));
fn.setReturnType(type);
this.type = type;
for (int i = 0; i < children.size(); ++i) {

View File

@ -248,14 +248,8 @@ public class OriginalPlanner extends Planner {
rootFragment.setSink(insertStmt.getDataSink());
insertStmt.complete();
List<Expr> exprs = statement.getResultExprs();
if (analyzer.getContext().getConnectionId() == 0) {
// stream load tvf
rootFragment.setOutputExprs(exprs);
} else {
List<Expr> resExprs = Expr.substituteList(exprs, rootFragment.getPlanRoot().getOutputSmap(), analyzer,
true);
rootFragment.setOutputExprs(resExprs);
}
rootFragment.setOutputExprs(
Expr.substituteList(exprs, rootFragment.getPlanRoot().getOutputSmap(), analyzer, true));
} else {
List<Expr> resExprs = Expr.substituteList(queryStmt.getResultExprs(),
rootFragment.getPlanRoot().getOutputSmap(), analyzer, false);