mirror of https://github.com/citusdata/citus.git
wip
parent
34422284de
commit
e4b8c7c183
|
@ -62,6 +62,8 @@ typedef struct AttributeEquivalenceClass
|
||||||
typedef struct FindRteIdentityContext {
|
typedef struct FindRteIdentityContext {
|
||||||
uint32 rteIdentity;
|
uint32 rteIdentity;
|
||||||
Query* query;
|
Query* query;
|
||||||
|
Query* temp;
|
||||||
|
bool found;
|
||||||
}FindRteIdentityContext;
|
}FindRteIdentityContext;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1775,7 +1777,7 @@ RelationRestrictionPartitionKeyIndex(Query* originalQuery, RelationRestriction *
|
||||||
FindRteIdentityContext* findRteIdentityContext = palloc0(sizeof(FindRteIdentityContext));
|
FindRteIdentityContext* findRteIdentityContext = palloc0(sizeof(FindRteIdentityContext));
|
||||||
findRteIdentityContext->rteIdentity = GetRTEIdentity(relationRestriction->rte);
|
findRteIdentityContext->rteIdentity = GetRTEIdentity(relationRestriction->rte);
|
||||||
findRteIdentityWalker((Node*) originalQuery, findRteIdentityContext);
|
findRteIdentityWalker((Node*) originalQuery, findRteIdentityContext);
|
||||||
if (findRteIdentityContext->query == NULL) {
|
if (!findRteIdentityContext->found) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
List *relationTargetList = findRteIdentityContext->query->targetList;
|
List *relationTargetList = findRteIdentityContext->query->targetList;
|
||||||
|
@ -1821,18 +1823,11 @@ findRteIdentityWalker(Node *node, FindRteIdentityContext* context)
|
||||||
if (IsA(node, Query))
|
if (IsA(node, Query))
|
||||||
{
|
{
|
||||||
Query *query = (Query *) node;
|
Query *query = (Query *) node;
|
||||||
RangeTblEntry* rte = NULL;
|
Query* prev = context->temp;
|
||||||
foreach_ptr(rte, query->rtable) {
|
context->temp = query;
|
||||||
if (rte->rtekind == RTE_RELATION) {
|
|
||||||
if (GetRTEIdentity(rte) == context->rteIdentity) {
|
|
||||||
context->query = query;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
query_tree_walker(query, findRteIdentityWalker, context,
|
query_tree_walker(query, findRteIdentityWalker, context,
|
||||||
QTW_EXAMINE_RTES_BEFORE);
|
QTW_EXAMINE_RTES_BEFORE);
|
||||||
|
context->temp = prev;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1841,6 +1836,14 @@ findRteIdentityWalker(Node *node, FindRteIdentityContext* context)
|
||||||
return expression_tree_walker(node, findRteIdentityWalker,
|
return expression_tree_walker(node, findRteIdentityWalker,
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
|
RangeTblEntry* rte = (RangeTblEntry*) node;
|
||||||
|
if (rte->rtekind == RTE_RELATION) {
|
||||||
|
if (GetRTEIdentity(rte) == context->rteIdentity) {
|
||||||
|
context->found = true;
|
||||||
|
context->query = context->temp;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,8 +236,12 @@ FROM
|
||||||
UNION ALL SELECT user_id AS user_id FROM users_table_part JOIN events_table_part USING (user_id) WHERE users_table_part.value_1 = 8 GROUP BY user_id)) AS bar
|
UNION ALL SELECT user_id AS user_id FROM users_table_part JOIN events_table_part USING (user_id) WHERE users_table_part.value_1 = 8 GROUP BY user_id)) AS bar
|
||||||
WHERE user_id < 2000 ) as level_1 ) as level_2 ) as level_3
|
WHERE user_id < 2000 ) as level_1 ) as level_2 ) as level_3
|
||||||
ORDER BY 1 DESC LIMIT 10;
|
ORDER BY 1 DESC LIMIT 10;
|
||||||
DEBUG: generating subplan XXX_1 for subquery SELECT user_id FROM union_pushdown.users_table_part WHERE (value_2 OPERATOR(pg_catalog.=) 3)
|
DEBUG: push down of limit count: 10
|
||||||
ERROR: complex joins are only supported when all distributed tables are co-located and joined on their distribution columns
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
78
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- safe to pushdown
|
-- safe to pushdown
|
||||||
SELECT DISTINCT user_id FROM (
|
SELECT DISTINCT user_id FROM (
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
|
|
Loading…
Reference in New Issue