diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java index 6a24aa6f5a71ae..117f7a5560244d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java @@ -581,8 +581,7 @@ public Optional handleQueryInFe(StatementBase parsedStmt) { return Optional.of(resultSet); } else if (child instanceof PhysicalEmptyRelation) { List columns = Lists.newArrayList(); - PhysicalEmptyRelation physicalEmptyRelation = (PhysicalEmptyRelation) physicalPlan.child(0); - for (int i = 0; i < physicalEmptyRelation.getProjects().size(); i++) { + for (int i = 0; i < physicalPlan.getOutput().size(); i++) { NamedExpression output = physicalPlan.getOutput().get(i); columns.add(new Column(output.getName(), output.getDataType().toCatalogDataType())); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputePrecisionForRound.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputePrecisionForRound.java index eedbfea6df9ac6..cd9629640de2c2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputePrecisionForRound.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputePrecisionForRound.java @@ -37,7 +37,8 @@ default FunctionSignature computePrecision(FunctionSignature signature) { Expression floatLength = getArgument(1); int scale; - if (floatLength.isLiteral() || (floatLength instanceof Cast && floatLength.child(0).isLiteral() + if ((floatLength.isLiteral() && floatLength.getDataType() instanceof Int32OrLessType) + || (floatLength instanceof Cast && floatLength.child(0).isLiteral() && floatLength.child(0).getDataType() instanceof Int32OrLessType)) { // Scale argument is a literal or cast from other literal if (floatLength instanceof Cast) { diff --git a/regression-test/suites/correctness_p0/test_cast_decimal.groovy b/regression-test/suites/correctness_p0/test_cast_decimal.groovy index 21a1ab6d0c3ee4..e7d5caa8f196c4 100644 --- a/regression-test/suites/correctness_p0/test_cast_decimal.groovy +++ b/regression-test/suites/correctness_p0/test_cast_decimal.groovy @@ -24,16 +24,6 @@ suite("test_cast_decimal") { sql """select cast(32123.34212456734 as decimal(3,2));""" contains "cast(32123.34212456734 as DECIMALV3(3, 2))" } - - - sql """ - set enable_nereids_planner=false; - """ - - explain { - sql """select cast(32123.34212456734 as decimal(3,2));""" - contains "CAST(32123.34212456734 AS DECIMALV3(3, 2))" - } sql """drop table if exists test_ttt""" sql """create table test_ttt(big_key bigint)DISTRIBUTED BY HASH(big_key) BUCKETS 1 PROPERTIES ("replication_num" = "1");"""