Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/custom_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,13 @@ chfdw_check_for_ordered_aggregate(Aggref* agg) {
}

/* Accept all ordered aggregates defined by pg_clickhouse. */
Oid extoid = getExtensionOfObject(ProcedureRelationId, agg->aggfnoid);
char* extname = get_extension_name(extoid);
Oid extoid = getExtensionOfObject(ProcedureRelationId, agg->aggfnoid);

return STR_EQUAL(extname, "pg_clickhouse");
if (!OidIsValid(extoid)) {
return false;
}

return get_extension_oid("pg_clickhouse", true) == extoid;
}

/*
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions_0.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions_2.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions_3.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions_4.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions_5.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions_6.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions_7.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
29 changes: 29 additions & 0 deletions test/expected/functions_8.out
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,35 @@ SELECT percentile_disc(ARRAY[0.25, 0.5, 0.75]) WITHIN GROUP (ORDER BY a NULLS LA
{2,2,2}
(1 row)

CREATE FUNCTION local_ordered_sfunc(integer, integer)
RETURNS integer
LANGUAGE SQL
IMMUTABLE
AS 'SELECT $1 + 1';
CREATE AGGREGATE local_ordered_count(ORDER BY integer) (
SFUNC = local_ordered_sfunc,
STYPE = integer,
INITCOND = '0'
);
EXPLAIN (VERBOSE, COSTS OFF)
SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate
Output: local_ordered_count() WITHIN GROUP (ORDER BY a)
-> Foreign Scan on public.t1
Output: a, b, c
Remote SQL: SELECT a FROM functions_test.t1
(5 rows)

SELECT local_ordered_count() WITHIN GROUP (ORDER BY a) FROM t1;
local_ordered_count
---------------------
4
(1 row)

DROP AGGREGATE local_ordered_count(integer);
DROP FUNCTION local_ordered_sfunc(integer, integer);
EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
Loading