From 0bc1f1360c52eef05ebd93c1d7eb47d98eb343c5 Mon Sep 17 00:00:00 2001 From: 924060929 Date: Thu, 19 Jun 2025 13:57:19 +0800 Subject: [PATCH 1/2] fix error message --- .../nereids/trees/plans/commands/insert/InsertUtils.java | 6 ++++++ regression-test/suites/insert_p0/insert.groovy | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java index 92e6f4826b03ca..6384e6a861048a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java @@ -416,6 +416,9 @@ private static Plan normalizePlanWithoutLock(LogicalPlan plan, TableIf table, castValue = rewriteContext == null ? castValue : FoldConstantRuleOnFE.evaluate(castValue, rewriteContext); + if (!(castValue instanceof NamedExpression)) { + castValue = new Alias(castValue); + } addColumnValue(analyzer, optimizedRowConstructor, (NamedExpression) castValue); } } @@ -439,6 +442,9 @@ private static Plan normalizePlanWithoutLock(LogicalPlan plan, TableIf table, castValue = rewriteContext == null ? castValue : FoldConstantRuleOnFE.evaluate(castValue, rewriteContext); + if (!(castValue instanceof NamedExpression)) { + castValue = new Alias(castValue); + } addColumnValue(analyzer, optimizedRowConstructor, (NamedExpression) castValue); } } diff --git a/regression-test/suites/insert_p0/insert.groovy b/regression-test/suites/insert_p0/insert.groovy index 23c32597e64295..fe5d1f11e62754 100644 --- a/regression-test/suites/insert_p0/insert.groovy +++ b/regression-test/suites/insert_p0/insert.groovy @@ -149,4 +149,9 @@ suite("insert") { def rows1 = sql """select count() from source;""" def rows2 = sql """select count() from dest;""" assertTrue(rows1 == rows2); + + test { + sql("insert into dest values(now(), 0xff, 0xaa)") + exception "Unknown column '0xff' in 'table list' in UNBOUND_OLAP_TABLE_SINK clause" + } } From dace1502087bc60748358613d2685d1b96549848 Mon Sep 17 00:00:00 2001 From: 924060929 Date: Thu, 19 Jun 2025 14:20:14 +0800 Subject: [PATCH 2/2] fix error message --- .../trees/plans/commands/insert/InsertUtils.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java index 6384e6a861048a..dbf1b92311ffe8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java @@ -416,9 +416,6 @@ private static Plan normalizePlanWithoutLock(LogicalPlan plan, TableIf table, castValue = rewriteContext == null ? castValue : FoldConstantRuleOnFE.evaluate(castValue, rewriteContext); - if (!(castValue instanceof NamedExpression)) { - castValue = new Alias(castValue); - } addColumnValue(analyzer, optimizedRowConstructor, (NamedExpression) castValue); } } @@ -442,9 +439,6 @@ private static Plan normalizePlanWithoutLock(LogicalPlan plan, TableIf table, castValue = rewriteContext == null ? castValue : FoldConstantRuleOnFE.evaluate(castValue, rewriteContext); - if (!(castValue instanceof NamedExpression)) { - castValue = new Alias(castValue); - } addColumnValue(analyzer, optimizedRowConstructor, (NamedExpression) castValue); } } @@ -535,16 +529,16 @@ value, new ExpressionRewriteContext(expressionAnalyzer.getCascadesContext()) optimizedRowConstructor.add(value); } - private static Expression castValue(Expression value, DataType targetType) { + private static Alias castValue(Expression value, DataType targetType) { if (value instanceof Alias) { Expression oldChild = value.child(0); Expression newChild = TypeCoercionUtils.castUnbound(oldChild, targetType); - return oldChild == newChild ? value : value.withChildren(newChild); + return (Alias) (oldChild == newChild ? value : value.withChildren(newChild)); } else if (value instanceof UnboundAlias) { UnboundAlias unboundAlias = (UnboundAlias) value; return new Alias(TypeCoercionUtils.castUnbound(unboundAlias.child(), targetType)); } else { - return TypeCoercionUtils.castUnbound(value, targetType); + return new Alias(TypeCoercionUtils.castUnbound(value, targetType)); } }