diff --git a/regression-test/suites/nereids_function_p0/agg_function/agg.groovy b/regression-test/suites/nereids_function_p0/agg_function/agg.groovy index 81c84ad32d8f7e..087ca2cf9f1ca6 100644 --- a/regression-test/suites/nereids_function_p0/agg_function/agg.groovy +++ b/regression-test/suites/nereids_function_p0/agg_function/agg.groovy @@ -2269,6 +2269,191 @@ suite("nereids_agg_fn") { qt_sql_sum_LargeInt_agg_phase_4_notnull ''' select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum(klint) from fn_test''' + qt_sql_sum0_Boolean ''' + select sum0(kbool) from fn_test''' + qt_sql_sum0_Boolean_gb ''' + select sum0(kbool) from fn_test group by id order by id''' + qt_sql_sum0_TinyInt_gb ''' + select sum0(ktint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_TinyInt ''' + select sum0(ktint) from fn_test''' + qt_sql_sum0_TinyInt_agg_phase_1 ''' + select count(id), sum0(ktint) from fn_test group by id order by id''' + qt_sql_sum0_TinyInt_agg_phase_2 ''' + select count(distinct id), sum0(ktint) from fn_test''' + qt_sql_sum0_TinyInt_agg_phase_3 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(ktint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_TinyInt_agg_phase_4 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(ktint) from fn_test''' + qt_sql_sum0_TinyInt_gb_notnull ''' + select sum0(ktint) from fn_test_not_nullable group by kbool order by kbool''' + qt_sql_sum0_TinyInt_notnull ''' + select sum0(ktint) from fn_test_not_nullable''' + qt_sql_sum0_TinyInt_agg_phase_1_notnull ''' + select count(id), sum0(ktint) from fn_test_not_nullable group by id order by id''' + qt_sql_sum0_TinyInt_agg_phase_2_notnull ''' + select count(distinct id), sum0(ktint) from fn_test_not_nullable''' + qt_sql_sum0_TinyInt_agg_phase_3_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(ktint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_TinyInt_agg_phase_4_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(ktint) from fn_test''' + + qt_sql_sum0_SmallInt_gb ''' + select sum0(ksint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_SmallInt ''' + select sum0(ksint) from fn_test''' + qt_sql_sum0_SmallInt_agg_phase_1 ''' + select count(id), sum0(ksint) from fn_test group by id order by id''' + qt_sql_sum0_SmallInt_agg_phase_2 ''' + select count(distinct id), sum0(ksint) from fn_test''' + qt_sql_sum0_SmallInt_agg_phase_3 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(ksint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_SmallInt_agg_phase_4 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(ksint) from fn_test''' + qt_sql_sum0_SmallInt_gb_notnull ''' + select sum0(ksint) from fn_test_not_nullable group by kbool order by kbool''' + qt_sql_sum0_SmallInt_notnull ''' + select sum0(ksint) from fn_test_not_nullable''' + qt_sql_sum0_SmallInt_agg_phase_1_notnull ''' + select count(id), sum0(ksint) from fn_test_not_nullable group by id order by id''' + qt_sql_sum0_SmallInt_agg_phase_2_notnull ''' + select count(distinct id), sum0(ksint) from fn_test_not_nullable''' + qt_sql_sum0_SmallInt_agg_phase_3_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(ksint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_SmallInt_agg_phase_4_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(ksint) from fn_test''' + + qt_sql_sum0_Integer_gb ''' + select sum0(kint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_Integer ''' + select sum0(kint) from fn_test''' + qt_sql_sum0_Integer_agg_phase_1 ''' + select count(id), sum0(kint) from fn_test group by id order by id''' + qt_sql_sum0_Integer_agg_phase_2 ''' + select count(distinct id), sum0(kint) from fn_test''' + qt_sql_sum0_Integer_agg_phase_3 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(kint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_Integer_agg_phase_4 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(kint) from fn_test''' + qt_sql_sum0_Integer_gb_notnull ''' + select sum0(kint) from fn_test_not_nullable group by kbool order by kbool''' + qt_sql_sum0_Integer_notnull ''' + select sum0(kint) from fn_test_not_nullable''' + qt_sql_sum0_Integer_agg_phase_1_notnull ''' + select count(id), sum0(kint) from fn_test_not_nullable group by id order by id''' + qt_sql_sum0_Integer_agg_phase_2_notnull ''' + select count(distinct id), sum0(kint) from fn_test_not_nullable''' + qt_sql_sum0_Integer_agg_phase_3_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(kint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_Integer_agg_phase_4_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(kint) from fn_test''' + + qt_sql_sum0_BigInt_gb ''' + select sum0(kbint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_BigInt ''' + select sum0(kbint) from fn_test''' + qt_sql_sum0_BigInt_agg_phase_1 ''' + select count(id), sum0(kbint) from fn_test group by id order by id''' + qt_sql_sum0_BigInt_agg_phase_2 ''' + select count(distinct id), sum0(kbint) from fn_test''' + qt_sql_sum0_BigInt_agg_phase_3 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(kbint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_BigInt_agg_phase_4 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(kbint) from fn_test''' + qt_sql_sum0_BigInt_gb_notnull ''' + select sum0(kbint) from fn_test_not_nullable group by kbool order by kbool''' + qt_sql_sum0_BigInt_notnull ''' + select sum0(kbint) from fn_test_not_nullable''' + qt_sql_sum0_BigInt_agg_phase_1_notnull ''' + select count(id), sum0(kbint) from fn_test_not_nullable group by id order by id''' + qt_sql_sum0_BigInt_agg_phase_2_notnull ''' + select count(distinct id), sum0(kbint) from fn_test_not_nullable''' + qt_sql_sum0_BigInt_agg_phase_3_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(kbint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_BigInt_agg_phase_4_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(kbint) from fn_test''' + + //not cast float to double + explain { + sql("select sum0(kfloat) from fn_test;") + contains "partial_sum0(kfloat" + } + + qt_sql_sum0_Double_gb ''' + select sum0(kdbl) from fn_test group by kbool order by kbool''' + qt_sql_sum0_Double ''' + select sum0(kdbl) from fn_test''' + qt_sql_sum0_Double_agg_phase_1 ''' + select count(id), sum0(kdbl) from fn_test group by id order by id''' + qt_sql_sum0_Double_agg_phase_2 ''' + select count(distinct id), sum0(kdbl) from fn_test''' + qt_sql_sum0_Double_agg_phase_3 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(kdbl) from fn_test group by kbool order by kbool''' + qt_sql_sum0_Double_agg_phase_4 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(kdbl) from fn_test''' + qt_sql_sum0_Double_gb_notnull ''' + select sum0(kdbl) from fn_test_not_nullable group by kbool order by kbool''' + qt_sql_sum0_Double_notnull ''' + select sum0(kdbl) from fn_test_not_nullable''' + qt_sql_sum0_Double_agg_phase_1_notnull ''' + select count(id), sum0(kdbl) from fn_test_not_nullable group by id order by id''' + qt_sql_sum0_Double_agg_phase_2_notnull ''' + select count(distinct id), sum0(kdbl) from fn_test_not_nullable''' + qt_sql_sum0_Double_agg_phase_3_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(kdbl) from fn_test group by kbool order by kbool''' + qt_sql_sum0_Double_agg_phase_4_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(kdbl) from fn_test''' + + qt_sql_sum0_DecimalV2_gb ''' + select sum0(kdcmls1) from fn_test group by kbool order by kbool''' + qt_sql_sum0_DecimalV2 ''' + select sum0(kdcmls1) from fn_test''' + qt_sql_sum0_DecimalV2_agg_phase_1 ''' + select count(id), sum0(kdcmls1) from fn_test group by id order by id''' + qt_sql_sum0_DecimalV2_agg_phase_2 ''' + select count(distinct id), sum0(kdcmls1) from fn_test''' + qt_sql_sum0_DecimalV2_agg_phase_3 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(kdcmls1) from fn_test group by kbool order by kbool''' + qt_sql_sum0_DecimalV2_agg_phase_4 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(kdcmls1) from fn_test''' + qt_sql_sum0_DecimalV2_gb_notnull ''' + select sum0(kdcmls1) from fn_test_not_nullable group by kbool order by kbool''' + qt_sql_sum0_DecimalV2_notnull ''' + select sum0(kdcmls1) from fn_test_not_nullable''' + qt_sql_sum0_DecimalV2_agg_phase_1_notnull ''' + select count(id), sum0(kdcmls1) from fn_test_not_nullable group by id order by id''' + qt_sql_sum0_DecimalV2_agg_phase_2_notnull ''' + select count(distinct id), sum0(kdcmls1) from fn_test_not_nullable''' + qt_sql_sum0_DecimalV2_agg_phase_3_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(kdcmls1) from fn_test group by kbool order by kbool''' + qt_sql_sum0_DecimalV2_agg_phase_4_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(kdcmls1) from fn_test''' + + qt_sql_sum0_LargeInt_gb ''' + select sum0(klint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_LargeInt ''' + select sum0(klint) from fn_test''' + qt_sql_sum0_LargeInt_agg_phase_1 ''' + select count(id), sum0(klint) from fn_test group by id order by id''' + qt_sql_sum0_LargeInt_agg_phase_2 ''' + select count(distinct id), sum0(klint) from fn_test''' + qt_sql_sum0_LargeInt_agg_phase_3 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(klint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_LargeInt_agg_phase_4 ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(klint) from fn_test''' + qt_sql_sum0_LargeInt_gb_notnull ''' + select sum0(klint) from fn_test_not_nullable group by kbool order by kbool''' + qt_sql_sum0_LargeInt_notnull ''' + select sum0(klint) from fn_test_not_nullable''' + qt_sql_sum0_LargeInt_agg_phase_1_notnull ''' + select count(id), sum0(klint) from fn_test_not_nullable group by id order by id''' + qt_sql_sum0_LargeInt_agg_phase_2_notnull ''' + select count(distinct id), sum0(klint) from fn_test_not_nullable''' + qt_sql_sum0_LargeInt_agg_phase_3_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id, kint), sum0(klint) from fn_test group by kbool order by kbool''' + qt_sql_sum0_LargeInt_agg_phase_4_notnull ''' + select /*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT, TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id), sum0(klint) from fn_test''' + qt_sql_topn_Varchar_Integer_gb ''' select topn(kvchrs1, 3) from fn_test group by kbool order by kbool''' qt_sql_topn_Varchar_Integer '''