Skip to content

Commit

Permalink
Fix bug with explain and Add more message about join type.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyue-hashdata committed Dec 5, 2024
1 parent 274d8aa commit 76a003a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/backend/commands/explain.c
Original file line number Diff line number Diff line change
Expand Up @@ -2296,8 +2296,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
/* fall through to print additional fields the same as SeqScan */
/* FALLTHROUGH */
case T_SeqScan:
show_pushdown_runtime_filter_info("Rows Removed by Pushdown Runtime Filter",
planstate, es);
if (IsA(planstate, SeqScanState))
show_pushdown_runtime_filter_info("Rows Removed by Pushdown Runtime Filter",
planstate, es);
/* FALLTHROUGH */
case T_ValuesScan:
case T_CteScan:
Expand Down
16 changes: 11 additions & 5 deletions src/backend/executor/nodeHashjoin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2195,13 +2195,19 @@ CreateRuntimeFilter(HashJoinState* hjstate)
List *targets;

/*
* Only applicatable for inner, right and semi join,
* A build-side Bloom filter tells us if a row is definitely not in the build
* side. This allows us to early-eliminate rows or early-accept rows depending
* on the type of join.
* Left Outer Join and Full Outer Join output all rows, so a build-side Bloom
* filter would only allow us to early-output. Left Antijoin outputs only if
* there is no match, so again early output. We don't implement early output
* for now.
* So it's only applicatable for inner, right and semi join.
*/
jointype = hjstate->js.jointype;
if (jointype != JOIN_INNER
&& jointype != JOIN_RIGHT
&& jointype != JOIN_SEMI
)
if (jointype != JOIN_INNER &&
jointype != JOIN_RIGHT &&
jointype != JOIN_SEMI)
return;

hstate = castNode(HashState, innerPlanState(hjstate));
Expand Down
19 changes: 19 additions & 0 deletions src/test/regress/expected/gp_runtime_filter.out
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,25 @@ SELECT * FROM t1, t2 WHERE t1.c2 = t2.c2;
RESET gp_enable_runtime_filter_pushdown;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
-- case3: bug fix with explain
DROP TABLE IF EXISTS test_tablesample;
NOTICE: table "test_tablesample" does not exist, skipping
CREATE TABLE test_tablesample (dist int, id int, name text) WITH (fillfactor=10) DISTRIBUTED BY (dist);
INSERT INTO test_tablesample SELECT 0, i, repeat(i::text, 875) FROM generate_series(0, 9) s(i) ORDER BY i;
INSERT INTO test_tablesample SELECT 3, i, repeat(i::text, 875) FROM generate_series(10, 19) s(i) ORDER BY i;
INSERT INTO test_tablesample SELECT 5, i, repeat(i::text, 875) FROM generate_series(20, 29) s(i) ORDER BY i;
SET gp_enable_runtime_filter_pushdown TO on;
EXPLAIN (COSTS OFF) SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (2);
QUERY PLAN
--------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3)
-> Sample Scan on test_tablesample
Sampling: system ('50'::real) REPEATABLE ('2'::double precision)
Optimizer: Postgres query optimizer
(4 rows)

RESET gp_enable_runtime_filter_pushdown;
DROP TABLE IF EXISTS test_tablesample;
-- Clean up: reset guc
SET gp_enable_runtime_filter TO off;
SET optimizer TO default;
13 changes: 13 additions & 0 deletions src/test/regress/sql/gp_runtime_filter.sql
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ RESET gp_enable_runtime_filter_pushdown;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;

-- case3: bug fix with explain
DROP TABLE IF EXISTS test_tablesample;
CREATE TABLE test_tablesample (dist int, id int, name text) WITH (fillfactor=10) DISTRIBUTED BY (dist);
INSERT INTO test_tablesample SELECT 0, i, repeat(i::text, 875) FROM generate_series(0, 9) s(i) ORDER BY i;
INSERT INTO test_tablesample SELECT 3, i, repeat(i::text, 875) FROM generate_series(10, 19) s(i) ORDER BY i;
INSERT INTO test_tablesample SELECT 5, i, repeat(i::text, 875) FROM generate_series(20, 29) s(i) ORDER BY i;

SET gp_enable_runtime_filter_pushdown TO on;
EXPLAIN (COSTS OFF) SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (2);
RESET gp_enable_runtime_filter_pushdown;

DROP TABLE IF EXISTS test_tablesample;

-- Clean up: reset guc
SET gp_enable_runtime_filter TO off;
SET optimizer TO default;

0 comments on commit 76a003a

Please sign in to comment.