fix problem that smp do not support median

This commit is contained in:
yanghao
2021-03-14 13:20:29 +08:00
parent eeafa3a03e
commit 0f90960368
5 changed files with 1149 additions and 13 deletions

View File

@ -9282,7 +9282,27 @@ static List* add_agg_node_to_tlist(List* remote_tlist, Node* expr, Index ressort
}
return remote_tlist;
}
#ifndef ENABLE_MULTIPLE_NODES
static bool check_median_walker(Node* node, void* context)
{
if (node == NULL) {
return false;
} else if (IsA(node, Aggref)) {
Aggref* agg_node = (Aggref*)node;
/* 5555 and 5556 is median's fn oid */
if (agg_node->aggfnoid == 5555 || agg_node->aggfnoid == 5556) {
errno_t sprintf_rc = sprintf_s(u_sess->opt_cxt.not_shipping_info->not_shipping_reason,
NOTPLANSHIPPING_LENGTH,
"median aggregate is not supported in stream plan");
securec_check_ss_c(sprintf_rc, "\0", "\0");
mark_stream_unsupport();
}
return false;
}
return expression_tree_walker(node, (bool (*)())check_median_walker, context);
}
#endif
/*
* process_agg_targetlist
* The function scans the targetlist to check if the we can push anything
@ -9321,18 +9341,7 @@ List* process_agg_targetlist(PlannerInfo* root, List** local_tlist)
foreign_qual_context context;
#ifndef ENABLE_MULTIPLE_NODES
/* smp do not support median aggregate */
if (IsA(expr, Aggref)) {
Aggref* agg_node = (Aggref*)expr;
/* 5556 is median's fn oid */
if (agg_node->aggfnoid == 5556) {
errno_t sprintf_rc = sprintf_s(u_sess->opt_cxt.not_shipping_info->not_shipping_reason,
NOTPLANSHIPPING_LENGTH,
"median aggregate is not supported in stream plan");
securec_check_ss_c(sprintf_rc, "\0", "\0");
mark_stream_unsupport();
}
}
check_median_walker(expr, NULL);
#endif
foreign_qual_context_init(&context);

File diff suppressed because it is too large Load Diff

View File

@ -758,3 +758,5 @@ test: leaky_function_operator
# gs_guc test
# ----------
#test: gs_guc
test: smp

View File

@ -521,4 +521,4 @@ test: llvm_vecsort llvm_vecsort2
test: udf_crem create_c_function
test: smp

View File

@ -0,0 +1,57 @@
create schema test_smp;
set search_path=test_smp;
create table t1(a int, b int, c int, d bigint);
insert into t1 values(generate_series(1, 100), generate_series(1, 10), generate_series(1, 2), generate_series(1, 50));
create table t2(a int, b int);
insert into t2 values(generate_series(1, 10), generate_series(1, 30));
create table t3(a int, b int, c int);
insert into t3 values(generate_series(1, 50), generate_series(1, 100), generate_series(1, 10));
analyze t1;
analyze t2;
analyze t3;
set query_dop=1002;
explain (costs off) select * from t2 order by 1,2;
select * from t2 order by 1,2;
set enable_nestloop=on;
set enable_mergejoin=off;
set enable_hashjoin=off;
explain (costs off) select t1.a,t2.b from t1, t2 where t1.a = t2.a order by 1,2;
select t1.a,t2.b from t1, t2 where t1.a = t2.a order by 1,2;
set enable_nestloop=off;
set enable_hashjoin=on;
explain (costs off) select t1.a,t2.b,t3.c from t1, t2, t3 where t1.a = t2.a and t1.b = t3.c order by 1,2,3;
select t1.a,t2.b,t3.c from t1, t2, t3 where t1.a = t2.a and t1.b = t3.c order by 1,2,3;
set enable_nestloop=on;
explain (costs off) select a, avg(b), sum(c) from t1 group by a order by 1,2,3;
select a, avg(b), sum(c) from t1 group by a order by 1,2,3;
explain (costs off) select median(a) from t1;
select median(a) from t1;
explain (costs off) select sum(b)+median(a) as result from t1;
select sum(b)+median(a) as result from t1;
explain (costs off) select a, count(distinct b) from t1 group by a order by 1 limit 10;
select a, count(distinct b) from t1 group by a order by 1 limit 10;
explain (costs off) select count(distinct b), count(distinct c) from t1 limit 10;
select count(distinct b), count(distinct c) from t1 limit 10;
explain (costs off) select distinct b from t1 union all select distinct a from t2 order by 1;
select distinct b from t1 union all select distinct a from t2 order by 1;
explain (costs off) select * from t1 where t1.a in (select t2.a from t2, t3 where t2.b = t3.c) order by 1,2,3;
select * from t1 where t1.a in (select t2.a from t2, t3 where t2.b = t3.c) order by 1,2,3;
explain (costs off) with s1 as (select t1.a as a, t3.b as b from t1,t3 where t1.b=t3.c) select * from t2, s1 where t2.b=s1.a order by 1,2,3,4;
with s1 as (select t1.a as a, t3.b as b from t1,t3 where t1.b=t3.c) select * from t2, s1 where t2.b=s1.a order by 1,2,3,4;
--clean
set search_path=public;
drop schema test_smp cascade;