Skip to content

Commit 13a3dc4

Browse files
zhangyue-hashdatamy-ship-it
authored andcommitted
Fix invalid attribute mapping when runtime filter pushdown is enabled.
Seqscan is a special case, it's targetlist is a projection of the relation's attributes, so we need to find the attribute number of the column in the relation. While TargetEntry::resno is just the attribute number for dynamic seqscan.
1 parent a7659f6 commit 13a3dc4

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/backend/executor/nodeHashjoin.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,6 +2341,18 @@ CheckTargetNode(PlanState *node, AttrNumber attno, AttrNumber *lattno)
23412341
if (!IsA(te->expr, Var))
23422342
return false;
23432343

2344+
if (IsA(node, DynamicSeqScanState))
2345+
{
2346+
*lattno = te->resno;
2347+
return true;
2348+
}
2349+
2350+
/*
2351+
* seqscan is a special case, it's targetlist is a projection of the
2352+
* relation's attributes. so we need to find the attribute number of the
2353+
* column in the relation, because PassByBloomFilter runs before
2354+
* projection in seqscan.
2355+
*/
23442356
var = castNode(Var, te->expr);
23452357

23462358
/* system column is not allowed */

src/test/regress/expected/gp_runtime_filter.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ INSERT INTO t2 SELECT generate_series(51, 51), generate_series(51, 51);
548548
ANALYZE;
549549
SET optimizer TO on;
550550
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
551-
SELECT * FROM t1, t2 WHERE t1.c2 = t2.c2;
551+
SELECT t1.c2 FROM t1, t2 WHERE t1.c2 = t2.c2;
552552
QUERY PLAN
553553
-------------------------------------------------------------------------------------------
554554
Gather Motion 3:1 (slice1; segments: 3) (actual rows=96 loops=1)
@@ -567,7 +567,7 @@ SELECT * FROM t1, t2 WHERE t1.c2 = t2.c2;
567567

568568
SET gp_enable_runtime_filter_pushdown TO on;
569569
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
570-
SELECT * FROM t1, t2 WHERE t1.c2 = t2.c2;
570+
SELECT t1.c2 FROM t1, t2 WHERE t1.c2 = t2.c2;
571571
QUERY PLAN
572572
-------------------------------------------------------------------------------------------
573573
Gather Motion 3:1 (slice1; segments: 3) (actual rows=96 loops=1)

src/test/regress/sql/gp_runtime_filter.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ ANALYZE;
242242
SET optimizer TO on;
243243

244244
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
245-
SELECT * FROM t1, t2 WHERE t1.c2 = t2.c2;
245+
SELECT t1.c2 FROM t1, t2 WHERE t1.c2 = t2.c2;
246246

247247
SET gp_enable_runtime_filter_pushdown TO on;
248248

249249
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
250-
SELECT * FROM t1, t2 WHERE t1.c2 = t2.c2;
250+
SELECT t1.c2 FROM t1, t2 WHERE t1.c2 = t2.c2;
251251

252252
RESET gp_enable_runtime_filter_pushdown;
253253

0 commit comments

Comments
 (0)