mirror of https://github.com/citusdata/citus.git
Merge pull request #660 from citusdata/outer_join_fix_for_flattened_queries
Prevent outer join crash when subquery is flattenpull/662/head
commit
0782b8f34e
|
@ -163,9 +163,20 @@ FixedJoinOrderList(FromExpr *fromExpr, List *tableEntryList)
|
||||||
TableEntry *nextTable = NULL;
|
TableEntry *nextTable = NULL;
|
||||||
JoinOrderNode *nextJoinNode = NULL;
|
JoinOrderNode *nextJoinNode = NULL;
|
||||||
List *candidateShardList = NIL;
|
List *candidateShardList = NIL;
|
||||||
|
Node *rightArg = joinExpr->rarg;
|
||||||
|
|
||||||
/* get the table on the right hand side of the join */
|
/* get the table on the right hand side of the join */
|
||||||
nextRangeTableRef = (RangeTblRef *) joinExpr->rarg;
|
if (IsA(rightArg, RangeTblRef))
|
||||||
|
{
|
||||||
|
nextRangeTableRef = (RangeTblRef *) rightArg;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
|
errmsg("cannot perform distributed planning on this query"),
|
||||||
|
errdetail("Subqueries in outer joins are not supported")));
|
||||||
|
}
|
||||||
|
|
||||||
nextTable = FindTableEntry(tableEntryList, nextRangeTableRef->rtindex);
|
nextTable = FindTableEntry(tableEntryList, nextRangeTableRef->rtindex);
|
||||||
|
|
||||||
if (joinType == JOIN_INNER)
|
if (joinType == JOIN_INNER)
|
||||||
|
|
|
@ -388,6 +388,24 @@ FROM
|
||||||
test(c_custkey, c_nationkey)
|
test(c_custkey, c_nationkey)
|
||||||
INNER JOIN multi_outer_join_third t1 ON (test.c_custkey = t1.t_custkey);
|
INNER JOIN multi_outer_join_third t1 ON (test.c_custkey = t1.t_custkey);
|
||||||
|
|
||||||
|
-- flattened out subqueries with outer joins are not supported
|
||||||
|
SELECT
|
||||||
|
l1.l_custkey,
|
||||||
|
count(*) as cnt
|
||||||
|
FROM (
|
||||||
|
SELECT l_custkey, l_nationkey
|
||||||
|
FROM multi_outer_join_left
|
||||||
|
WHERE l_comment like '%a%'
|
||||||
|
) l1
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT r_custkey, r_name
|
||||||
|
FROM multi_outer_join_right
|
||||||
|
WHERE r_comment like '%b%'
|
||||||
|
) l2 ON l1.l_custkey = l2.r_custkey
|
||||||
|
GROUP BY l1.l_custkey
|
||||||
|
ORDER BY cnt DESC, l1.l_custkey DESC
|
||||||
|
LIMIT 20;
|
||||||
|
|
||||||
-- Add a shard to the left table that overlaps with multiple shards in the right
|
-- Add a shard to the left table that overlaps with multiple shards in the right
|
||||||
\STAGE multi_outer_join_left FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
\STAGE multi_outer_join_left FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||||
|
|
||||||
|
|
|
@ -732,6 +732,25 @@ LOG: join order: [ "multi_outer_join_right" ][ local partition join "multi_oute
|
||||||
20
|
20
|
||||||
(20 rows)
|
(20 rows)
|
||||||
|
|
||||||
|
-- flattened out subqueries with outer joins are not supported
|
||||||
|
SELECT
|
||||||
|
l1.l_custkey,
|
||||||
|
count(*) as cnt
|
||||||
|
FROM (
|
||||||
|
SELECT l_custkey, l_nationkey
|
||||||
|
FROM multi_outer_join_left
|
||||||
|
WHERE l_comment like '%a%'
|
||||||
|
) l1
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT r_custkey, r_name
|
||||||
|
FROM multi_outer_join_right
|
||||||
|
WHERE r_comment like '%b%'
|
||||||
|
) l2 ON l1.l_custkey = l2.r_custkey
|
||||||
|
GROUP BY l1.l_custkey
|
||||||
|
ORDER BY cnt DESC, l1.l_custkey DESC
|
||||||
|
LIMIT 20;
|
||||||
|
ERROR: cannot perform distributed planning on this query
|
||||||
|
DETAIL: Subqueries in outer joins are not supported
|
||||||
-- Add a shard to the left table that overlaps with multiple shards in the right
|
-- Add a shard to the left table that overlaps with multiple shards in the right
|
||||||
\STAGE multi_outer_join_left FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
\STAGE multi_outer_join_left FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||||
-- All outer joins should error out
|
-- All outer joins should error out
|
||||||
|
|
Loading…
Reference in New Issue