mirror of https://github.com/citusdata/citus.git
Merge pull request #5835 from citusdata/velioglu/poly_aggregate
Add support for zero-argument polymorphic aggregatespull/5818/head
commit
83b0e98595
|
@ -966,6 +966,14 @@ GetAggregateDDLCommand(const RegProcedure funcOid, bool useCreateOrReplace)
|
|||
insertorderbyat = agg->aggnumdirectargs;
|
||||
}
|
||||
|
||||
/*
|
||||
* For zero-argument aggregate, write * in place of the list of arguments
|
||||
*/
|
||||
if (numargs == 0)
|
||||
{
|
||||
appendStringInfo(&buf, "*");
|
||||
}
|
||||
|
||||
for (i = 0; i < numargs; i++)
|
||||
{
|
||||
Oid argtype = argtypes[i];
|
||||
|
|
|
@ -1189,6 +1189,28 @@ DROP TABLE dummy_tbl CASCADE;
|
|||
NOTICE: drop cascades to 2 other objects
|
||||
DETAIL: drop cascades to function dummy_fnc(dummy_tbl,double precision)
|
||||
drop cascades to function dependent_agg(double precision)
|
||||
-- Show that polymorphic aggregates with zero-argument works
|
||||
CREATE FUNCTION stfnp_zero_arg(int[]) RETURNS int[] AS
|
||||
'select $1' LANGUAGE SQL;
|
||||
CREATE FUNCTION ffp_zero_arg(anyarray) RETURNS anyarray AS
|
||||
'select $1' LANGUAGE SQL;
|
||||
CREATE AGGREGATE zero_arg_agg(*) (SFUNC = stfnp_zero_arg, STYPE = int4[],
|
||||
FINALFUNC = ffp_zero_arg, INITCOND = '{}');
|
||||
CREATE TABLE zero_arg_agg_table(f1 int, f2 int[]);
|
||||
SELECT create_distributed_table('zero_arg_agg_table','f1');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO zero_arg_agg_table VALUES(1, array[1]);
|
||||
INSERT INTO zero_arg_agg_table VALUES(1, array[11]);
|
||||
SELECT zero_arg_agg(*) from zero_arg_agg_table;
|
||||
zero_arg_agg
|
||||
---------------------------------------------------------------------
|
||||
{}
|
||||
(1 row)
|
||||
|
||||
-- Show that after dropping a table on which functions and aggregates depending on
|
||||
-- pg_dist_object is consistent on coordinator and worker node.
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid)::text
|
||||
|
|
|
@ -603,6 +603,23 @@ SELECT run_command_on_workers($$select aggfnoid from pg_aggregate where aggfnoid
|
|||
|
||||
DROP TABLE dummy_tbl CASCADE;
|
||||
|
||||
-- Show that polymorphic aggregates with zero-argument works
|
||||
CREATE FUNCTION stfnp_zero_arg(int[]) RETURNS int[] AS
|
||||
'select $1' LANGUAGE SQL;
|
||||
|
||||
CREATE FUNCTION ffp_zero_arg(anyarray) RETURNS anyarray AS
|
||||
'select $1' LANGUAGE SQL;
|
||||
|
||||
CREATE AGGREGATE zero_arg_agg(*) (SFUNC = stfnp_zero_arg, STYPE = int4[],
|
||||
FINALFUNC = ffp_zero_arg, INITCOND = '{}');
|
||||
|
||||
CREATE TABLE zero_arg_agg_table(f1 int, f2 int[]);
|
||||
SELECT create_distributed_table('zero_arg_agg_table','f1');
|
||||
INSERT INTO zero_arg_agg_table VALUES(1, array[1]);
|
||||
INSERT INTO zero_arg_agg_table VALUES(1, array[11]);
|
||||
|
||||
SELECT zero_arg_agg(*) from zero_arg_agg_table;
|
||||
|
||||
-- Show that after dropping a table on which functions and aggregates depending on
|
||||
-- pg_dist_object is consistent on coordinator and worker node.
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid)::text
|
||||
|
|
Loading…
Reference in New Issue