diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UniqueFunctionTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UniqueFunctionTest.java index e0a6986492c07a..0f16a266f491a2 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UniqueFunctionTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/scalar/UniqueFunctionTest.java @@ -169,7 +169,8 @@ void testNoAggregate2() { Map exprIdToOriginExprMap = getExprIdToOriginExpressionMap(root); LogicalProject project = (LogicalProject) root.child(0); - Assertions.assertEquals(ImmutableList.of("a + random()", "a + random()", + Assertions.assertEquals(ImmutableList.of("(a + random()) AS `a + random()`", + "(a + random()) AS `a + random()`", "sum(a + random()) over(partition by a + random())", "sum(a + random()) over(partition by a + random())"), toSqls(project.getProjects())); checkOutputDifferent(project, expressionSet, exprIdToOriginExprMap); @@ -811,7 +812,8 @@ void testAggregateWithGroupBy5() { LogicalProject project = (LogicalProject) root.child(0); Assertions.assertEquals(ImmutableList.of("a + random()", "a + random() + 1", "a + random() + 2", - "sum(a + random())", "sum(a + random() + 1)", "sum(a + random() + 2)", + "sum(a + random()) AS `sum(a + random())`", "sum(a + random() + 1) AS `sum(a + random() + 1)`", + "sum((a + random() + cast(2 as DOUBLE))) AS `sum(a + random() + 2)`", "sum(a + random()) over()", "sum(a + random() + 1) over()", "sum(a + random() + 2) over()"), toSqls(project.getProjects())); Lists.transform(ImmutableList.of(0, 2, 3, 5, 6, 8), project.getProjects()::get).forEach(random0EqualValidator::checkRandomEqual); diff --git a/regression-test/data/nereids_rules_p0/unique_function/agg_with_unique_function.out b/regression-test/data/nereids_rules_p0/unique_function/agg_with_unique_function.out index 00ea2481b25fd0..a59eb1d160d45e 100644 --- a/regression-test/data/nereids_rules_p0/unique_function/agg_with_unique_function.out +++ b/regression-test/data/nereids_rules_p0/unique_function/agg_with_unique_function.out @@ -16,38 +16,38 @@ PhysicalResultSink -- !check_equal_no_agg_4_shape -- PhysicalResultSink ---PhysicalProject[a + random(), a + random(), sum(a + random()) over() AS `sum(a + random()) over()`, sum(a + random()) over() AS `sum(a + random()) over()`] +--PhysicalProject[(a + random()) AS `a + random()`, (a + random()) AS `a + random()`, sum(a + random()) over() AS `sum(a + random()) over()`, sum(a + random()) over() AS `sum(a + random()) over()`] ----PhysicalWindow -------PhysicalProject[(a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `a + random()`, (a + random()) AS `a + random()`] +------PhysicalProject[(a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, tbl_unique_function_with_one_row.a] --------PhysicalOlapScan[tbl_unique_function_with_one_row] -- !check_equal_no_agg_5_shape -- PhysicalResultSink ---PhysicalProject[a + random(), a + random()] +--PhysicalProject[(a + random()) AS `a + random()`, (a + random()) AS `a + random()`] ----filter((sum((a + random())) OVER() > 0.01) and (sum((a + random())) OVER(PARTITION BY (a + random())) > 0.01)) ------PhysicalWindow --------PhysicalWindow ----------PhysicalQuickSort[LOCAL_SORT] -------------PhysicalProject[(a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `a + random()`, (a + random()) AS `a + random()`] +------------PhysicalProject[(a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, tbl_unique_function_with_one_row.a] --------------PhysicalOlapScan[tbl_unique_function_with_one_row] -- !check_equal_no_agg_6_shape -- PhysicalResultSink ---PhysicalProject[a + random(), a + random(), sum(a + random()) over (partition by a + random())] +--PhysicalProject[(a + random()) AS `a + random()`, (a + random()) AS `a + random()`, sum(a + random()) over (partition by a + random())] ----filter((sum((a + random())) OVER() > 0.01) and (sum((a + random())) OVER(PARTITION BY (a + random())) > 0.01)) ------PhysicalWindow --------PhysicalWindow ----------PhysicalQuickSort[LOCAL_SORT] ------------PhysicalWindow --------------PhysicalQuickSort[LOCAL_SORT] -----------------PhysicalProject[(a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `a + random()`, (a + random()) AS `a + random()`] +----------------PhysicalProject[(a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, (a + random()) AS `(a + random())`, tbl_unique_function_with_one_row.a] ------------------PhysicalOlapScan[tbl_unique_function_with_one_row] -- !check_equal_one_row_to_agg_1_shape -- PhysicalResultSink ---PhysicalProject[random(), random(), sum(random()), sum(random()), sum(random()) over() AS `sum(random()) over()`, sum(random()) over() AS `sum(random()) over()`] +--PhysicalProject[random() AS `random()`, random() AS `random()`, sum(random()), sum(random()), sum(random()) over() AS `sum(random()) over()`, sum(random()) over() AS `sum(random()) over()`] ----PhysicalWindow -------PhysicalProject[random() AS `random()`, random() AS `random()`, random() AS `random()`, random() AS `random()`, sum(random()), sum(random())] +------PhysicalProject[random() AS `random()`, random() AS `random()`, sum(random()), sum(random())] --------hashAgg[GLOBAL] ----------hashAgg[LOCAL] ------------PhysicalProject[random() AS `random()`, random() AS `random()`] @@ -168,37 +168,34 @@ PhysicalResultSink -- !check_equal_agg_with_groupby_7_shape -- PhysicalResultSink ---PhysicalProject[a + random(), a + random() AS `a + random()`, sum(a + random()), sum(a + random()) over() AS `sum(a + random()) over()`] +--PhysicalProject[a + random(), a + random() AS `a + random()`, sum(a + random()) AS `sum(a + random())`, sum(a + random()) over() AS `sum(a + random()) over()`] ----PhysicalWindow -------PhysicalProject[a + random() AS `a + random()`, sum(a + random()) AS `sum(a + random())`] ---------hashAgg[GLOBAL] -----------hashAgg[LOCAL] -------------PhysicalProject[(a + random()) AS `a + random()`] ---------------PhysicalOlapScan[tbl_unique_function_with_one_row] +------hashAgg[GLOBAL] +--------hashAgg[LOCAL] +----------PhysicalProject[(a + random()) AS `a + random()`] +------------PhysicalOlapScan[tbl_unique_function_with_one_row] -- !check_equal_agg_with_groupby_8_shape -- PhysicalResultSink ---PhysicalProject[a + random(), a + random() AS `a + random()`, sum(a + random()), sum(a + random()) over() AS `sum(a + random()) over()`] +--PhysicalProject[a + random(), a + random() AS `a + random()`, sum(a + random()) AS `sum(a + random())`, sum(a + random()) over() AS `sum(a + random()) over()`] ----PhysicalWindow -------PhysicalProject[a + random() AS `a + random()`, sum(a + random()) AS `sum(a + random())`] ---------hashAgg[GLOBAL] -----------hashAgg[LOCAL] -------------filter((a + random() > 0.01)) ---------------PhysicalProject[(a + random()) AS `a + random()`] -----------------PhysicalOlapScan[tbl_unique_function_with_one_row] +------hashAgg[GLOBAL] +--------hashAgg[LOCAL] +----------filter((a + random() > 0.01)) +------------PhysicalProject[(a + random()) AS `a + random()`] +--------------PhysicalOlapScan[tbl_unique_function_with_one_row] -- !check_equal_agg_with_groupby_9_shape -- PhysicalResultSink --PhysicalQuickSort[MERGE_SORT] ----PhysicalQuickSort[LOCAL_SORT] -------PhysicalProject[a + random(), a + random() AS `a + random()`, abs(a + random()), sum(a + random()), sum(a + random()) over() AS `sum(a + random()) over()`] +------PhysicalProject[a + random(), a + random() AS `a + random()`, abs(a + random()) AS `abs(a + random())`, sum(a + random()) AS `sum(a + random())`, sum(a + random()) over() AS `sum(a + random()) over()`] --------PhysicalWindow -----------PhysicalProject[a + random() AS `a + random()`, abs(a + random()) AS `abs(a + random())`, sum(a + random()) AS `sum(a + random())`] -------------hashAgg[GLOBAL] ---------------hashAgg[LOCAL] -----------------filter((a + random() > 0.01)) -------------------PhysicalProject[(a + random()) AS `a + random()`] ---------------------PhysicalOlapScan[tbl_unique_function_with_one_row] +----------hashAgg[GLOBAL] +------------hashAgg[LOCAL] +--------------filter((a + random() > 0.01)) +----------------PhysicalProject[(a + random()) AS `a + random()`] +------------------PhysicalOlapScan[tbl_unique_function_with_one_row] -- !check_equal_agg_with_groupby_10_shape -- PhysicalResultSink