Skip to content

Commit

Permalink
Add test coverage for the aggregate push-down.
Browse files Browse the repository at this point in the history
Add new test file aggregate_pushdown.sql for testing aggregate
push-down feature. Add multiple alternate output files to adjust
with different outputs across server versions.

FDW-132, Suraj Kharage, reviewed by Vaibhav Dalvi, Jeevan Ladhe.
  • Loading branch information
jeevanladhe committed Nov 15, 2021
1 parent 8c6eafd commit 21efaea
Show file tree
Hide file tree
Showing 9 changed files with 5,638 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OBJS = connection.o option.o deparse.o mysql_query.o mysql_fdw.o
EXTENSION = mysql_fdw
DATA = mysql_fdw--1.0.sql mysql_fdw--1.1.sql mysql_fdw--1.0--1.1.sql

REGRESS = server_options connection_validation dml select pushdown join_pushdown
REGRESS = server_options connection_validation dml select pushdown join_pushdown aggregate_pushdown

MYSQL_CONFIG = mysql_config
PG_CPPFLAGS := $(shell $(MYSQL_CONFIG) --include)
Expand Down
1,068 changes: 1,068 additions & 0 deletions expected/aggregate_pushdown.out

Large diffs are not rendered by default.

1,068 changes: 1,068 additions & 0 deletions expected/aggregate_pushdown_1.out

Large diffs are not rendered by default.

1,073 changes: 1,073 additions & 0 deletions expected/aggregate_pushdown_2.out

Large diffs are not rendered by default.

1,052 changes: 1,052 additions & 0 deletions expected/aggregate_pushdown_3.out

Large diffs are not rendered by default.

1,068 changes: 1,068 additions & 0 deletions expected/aggregate_pushdown_4.out

Large diffs are not rendered by default.

41 changes: 5 additions & 36 deletions expected/select.out
Original file line number Diff line number Diff line change
Expand Up @@ -1097,20 +1097,13 @@ SELECT * FROM f_enum_t1 WHERE size = 'medium' ORDER BY id;

-- Remote aggregate in combination with a local Param (for the output
-- of an initplan)
EXPLAIN (VERBOSE, COSTS OFF)
SELECT EXISTS(SELECT 1 FROM pg_enum), sum(id) from f_enum_t1;
QUERY PLAN
----------------------------------------------------------------------
Aggregate
Output: $0, sum(f_enum_t1.id)
InitPlan 1 (returns $0)
-> Seq Scan on pg_catalog.pg_enum
-> Foreign Scan on public.f_enum_t1
Output: f_enum_t1.id, f_enum_t1.size
Remote query: SELECT `id` FROM `mysql_fdw_regress`.`enum_t1`
(7 rows)
exists | sum
--------+-----
t | 6
(1 row)

SELECT EXISTS(SELECT 1 FROM pg_enum), sum(id) from f_enum_t1;
SELECT EXISTS(SELECT 1 FROM pg_enum), sum(id) from f_enum_t1 GROUP BY 1;
exists | sum
--------+-----
t | 6
Expand Down Expand Up @@ -1250,30 +1243,6 @@ SELECT * FROM local_t1 lt1 WHERE lt1.c1 =
1 | SALES
(1 row)

EXPLAIN (VERBOSE, COSTS OFF)
SELECT c1, c2 FROM f_test_tbl1 WHERE c8 = (
SELECT c1 FROM f_test_tbl2 WHERE c1 = (
SELECT min(c1) + 1 FROM f_test_tbl2)) ORDER BY c1;
QUERY PLAN
-------------------------------------------------------------------------------------------------
Sort
Output: f_test_tbl1.c1, f_test_tbl1.c2
Sort Key: f_test_tbl1.c1
InitPlan 2 (returns $1)
-> Foreign Scan on public.f_test_tbl2 f_test_tbl2_1
Output: f_test_tbl2_1.c1
Remote query: SELECT `c1` FROM `mysql_fdw_regress`.`test_tbl2` WHERE ((`c1` = ?))
InitPlan 1 (returns $0)
-> Aggregate
Output: (min(f_test_tbl2.c1) + 1)
-> Foreign Scan on public.f_test_tbl2
Output: f_test_tbl2.c1, f_test_tbl2.c2, f_test_tbl2.c3
Remote query: SELECT `c1` FROM `mysql_fdw_regress`.`test_tbl2`
-> Foreign Scan on public.f_test_tbl1
Output: f_test_tbl1.c1, f_test_tbl1.c2
Remote query: SELECT `c1`, `c2` FROM `mysql_fdw_regress`.`test_tbl1` WHERE ((`c8` = ?))
(16 rows)

SELECT c1, c2 FROM f_test_tbl1 WHERE c8 = (
SELECT c1 FROM f_test_tbl2 WHERE c1 = (
SELECT min(c1) + 1 FROM f_test_tbl2)) ORDER BY c1;
Expand Down
302 changes: 302 additions & 0 deletions sql/aggregate_pushdown.sql

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions sql/select.sql
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,8 @@ SELECT * FROM f_enum_t1 WHERE size = 'medium' ORDER BY id;

-- Remote aggregate in combination with a local Param (for the output
-- of an initplan)
EXPLAIN (VERBOSE, COSTS OFF)
SELECT EXISTS(SELECT 1 FROM pg_enum), sum(id) from f_enum_t1;
SELECT EXISTS(SELECT 1 FROM pg_enum), sum(id) from f_enum_t1;
SELECT EXISTS(SELECT 1 FROM pg_enum), sum(id) from f_enum_t1 GROUP BY 1;

-- Check with the IMPORT FOREIGN SCHEMA command. Also, check ENUM types with
-- the IMPORT FOREIGN SCHEMA command. If the enum name is the same for multiple
Expand Down Expand Up @@ -363,10 +362,6 @@ SELECT c1, c2 FROM f_test_tbl2 WHERE c3 = (SELECT 'PUNE'::varchar) ORDER BY c1;
SELECT * FROM local_t1 lt1 WHERE lt1.c1 =
(SELECT count(*) FROM f_test_tbl3 ft1 WHERE ft1.c2 = lt1.c2) ORDER BY lt1.c1;

EXPLAIN (VERBOSE, COSTS OFF)
SELECT c1, c2 FROM f_test_tbl1 WHERE c8 = (
SELECT c1 FROM f_test_tbl2 WHERE c1 = (
SELECT min(c1) + 1 FROM f_test_tbl2)) ORDER BY c1;
SELECT c1, c2 FROM f_test_tbl1 WHERE c8 = (
SELECT c1 FROM f_test_tbl2 WHERE c1 = (
SELECT min(c1) + 1 FROM f_test_tbl2)) ORDER BY c1;
Expand Down

0 comments on commit 21efaea

Please sign in to comment.