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..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 @@ -529,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)); } } 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" + } }