From d204817641e834df5961cda06a2f7267c4fda2d9 Mon Sep 17 00:00:00 2001 From: seawinde Date: Wed, 15 Nov 2023 07:48:50 +0800 Subject: [PATCH] fix some regression test --- .../org/apache/doris/nereids/parser/LogicalPlanBuilder.java | 4 ++++ .../sql_functions/conditional_functions/test_if_cast.out | 2 +- regression-test/suites/nereids_syntax_p0/bind_priority.groovy | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java index cb78729c791fd0..500c857d296bf0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java @@ -306,6 +306,7 @@ import org.apache.doris.nereids.trees.plans.LimitPhase; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.algebra.Aggregate; +import org.apache.doris.nereids.trees.plans.algebra.OneRowRelation; import org.apache.doris.nereids.trees.plans.algebra.SetOperation.Qualifier; import org.apache.doris.nereids.trees.plans.commands.AlterMTMVCommand; import org.apache.doris.nereids.trees.plans.commands.Command; @@ -2410,6 +2411,9 @@ private LogicalPlan withSelectQuerySpecification( } return new LogicalHaving<>(ExpressionUtils.extractConjunctionToSet( getExpression((havingClause.get().booleanExpression()))), project); + } else if (inputRelation instanceof OneRowRelation) { + // If OneRowRelation should not add project, because slot will be wrong when analyze + return withHaving(aggregate, havingClause); } else { LogicalPlan having = withHaving(aggregate, havingClause); return withProjection(having, selectColumnCtx, aggClause, isDistinct); diff --git a/regression-test/data/query_p0/sql_functions/conditional_functions/test_if_cast.out b/regression-test/data/query_p0/sql_functions/conditional_functions/test_if_cast.out index cf64c4da4ac13b..1fb288a7636df5 100644 --- a/regression-test/data/query_p0/sql_functions/conditional_functions/test_if_cast.out +++ b/regression-test/data/query_p0/sql_functions/conditional_functions/test_if_cast.out @@ -15,5 +15,5 @@ ["1970-01-01"] -- !select -- -[null] +[NULL] diff --git a/regression-test/suites/nereids_syntax_p0/bind_priority.groovy b/regression-test/suites/nereids_syntax_p0/bind_priority.groovy index 536dcddf06cf90..072587ed28eee4 100644 --- a/regression-test/suites/nereids_syntax_p0/bind_priority.groovy +++ b/regression-test/suites/nereids_syntax_p0/bind_priority.groovy @@ -116,7 +116,7 @@ suite("bind_priority") { test{ sql "SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1" - exception "a is ambiguous: a#0, a#1." + exception "a is ambiguous: a#1, a#2." } sql "drop table if exists duplicate_slot";