Merge pull request #3371 from citusdata/fix-task-tracker-row-gather-subquery

Fix row-gather for subqueries being handled by task-tracker
pull/3355/head
Philip Dubé 2020-01-10 02:03:38 +00:00 committed by GitHub
commit d855faf2b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 11 deletions

View File

@ -65,6 +65,7 @@
#include "optimizer/var.h" #include "optimizer/var.h"
#endif #endif
#include "optimizer/restrictinfo.h" #include "optimizer/restrictinfo.h"
#include "optimizer/tlist.h"
#include "parser/parse_relation.h" #include "parser/parse_relation.h"
#include "parser/parsetree.h" #include "parser/parsetree.h"
#include "utils/builtins.h" #include "utils/builtins.h"
@ -4221,7 +4222,18 @@ MapTaskList(MapMergeJob *mapMergeJob, List *filterTaskList)
} }
else else
{ {
partitionColumnName = ColumnName(partitionColumn, rangeTableList); TargetEntry *targetEntry = tlist_member((Expr *) partitionColumn,
filterQuery->targetList);
if (targetEntry != NULL)
{
/* targetEntry->resname may be NULL */
partitionColumnName = targetEntry->resname;
}
if (partitionColumnName == NULL)
{
partitionColumnName = ColumnName(partitionColumn, rangeTableList);
}
} }
foreach(filterTaskCell, filterTaskList) foreach(filterTaskCell, filterTaskList)

View File

@ -383,20 +383,30 @@ select * FROM (
(5 rows) (5 rows)
select * FROM ( select * FROM (
SELECT key, avg(distinct floor(agg1.val/2)) m from aggdata agg1 SELECT key k, avg(distinct floor(agg1.val/2)) m from aggdata agg1
group by key group by key
) subq; ) subq;
key | m k | m
--------------------------------------------------------------------- ---------------------------------------------------------------------
1 | 1 1 | 1
5 | 5 |
3 | 2 3 | 2
7 | 4 7 | 4
6 | 6 |
2 | 1.5 2 | 1.5
9 | 0 9 | 0
(7 rows) (7 rows)
-- Test TransformsSubqueryNode with group by not in FROM (failed in past)
select count(*) FROM (
SELECT avg(distinct floor(agg1.val/2)) m from aggdata agg1
group by key
) subq;
count
---------------------------------------------------------------------
7
(1 row)
RESET citus.task_executor_type; RESET citus.task_executor_type;
-- This fails due to table types not being managed properly -- This fails due to table types not being managed properly
select key, count(distinct aggdata) select key, count(distinct aggdata)

View File

@ -184,7 +184,13 @@ select * FROM (
) subq ORDER BY 2, 1 LIMIT 5; ) subq ORDER BY 2, 1 LIMIT 5;
select * FROM ( select * FROM (
SELECT key, avg(distinct floor(agg1.val/2)) m from aggdata agg1 SELECT key k, avg(distinct floor(agg1.val/2)) m from aggdata agg1
group by key
) subq;
-- Test TransformsSubqueryNode with group by not in FROM (failed in past)
select count(*) FROM (
SELECT avg(distinct floor(agg1.val/2)) m from aggdata agg1
group by key group by key
) subq; ) subq;