mirror of https://github.com/citusdata/citus.git
undo enabling set operations for INSERT .. SELECT
parent
4c41096370
commit
0644e72539
|
@ -721,24 +721,7 @@ AddToAttributeEquivalenceClass(AttributeEquivalenceClass **attributeEquivalanceC
|
||||||
|
|
||||||
varToBeAdded = (Var *) subqueryTargetEntry->expr;
|
varToBeAdded = (Var *) subqueryTargetEntry->expr;
|
||||||
|
|
||||||
/* we need to handle set operations separately */
|
if (varToBeAdded && IsA(varToBeAdded, Var) && varToBeAdded->varlevelsup == 0)
|
||||||
if (subquery->setOperations)
|
|
||||||
{
|
|
||||||
SetOperationStmt *unionStatement =
|
|
||||||
(SetOperationStmt *) subquery->setOperations;
|
|
||||||
|
|
||||||
RangeTblRef *leftRangeTableReference = (RangeTblRef *) unionStatement->larg;
|
|
||||||
RangeTblRef *rightRangeTableReference = (RangeTblRef *) unionStatement->rarg;
|
|
||||||
|
|
||||||
varToBeAdded->varno = leftRangeTableReference->rtindex;
|
|
||||||
AddToAttributeEquivalenceClass(attributeEquivalanceClass,
|
|
||||||
baseRelOptInfo->subroot, varToBeAdded);
|
|
||||||
|
|
||||||
varToBeAdded->varno = rightRangeTableReference->rtindex;
|
|
||||||
AddToAttributeEquivalenceClass(attributeEquivalanceClass,
|
|
||||||
baseRelOptInfo->subroot, varToBeAdded);
|
|
||||||
}
|
|
||||||
else if (varToBeAdded && IsA(varToBeAdded, Var) && varToBeAdded->varlevelsup == 0)
|
|
||||||
{
|
{
|
||||||
AddToAttributeEquivalenceClass(attributeEquivalanceClass,
|
AddToAttributeEquivalenceClass(attributeEquivalanceClass,
|
||||||
baseRelOptInfo->subroot, varToBeAdded);
|
baseRelOptInfo->subroot, varToBeAdded);
|
||||||
|
|
|
@ -879,16 +879,10 @@ MultiTaskRouterSelectQuerySupported(Query *query)
|
||||||
|
|
||||||
if (subquery->setOperations != NULL)
|
if (subquery->setOperations != NULL)
|
||||||
{
|
{
|
||||||
SetOperationStmt *setOperationStatement =
|
return DeferredError(ERRCODE_FEATURE_NOT_SUPPORTED,
|
||||||
(SetOperationStmt *) subquery->setOperations;
|
"Set operations are not allowed in INSERT ... SELECT "
|
||||||
|
"queries",
|
||||||
if (setOperationStatement->op != SETOP_UNION)
|
NULL, NULL);
|
||||||
{
|
|
||||||
return DeferredError(ERRCODE_FEATURE_NOT_SUPPORTED,
|
|
||||||
"INTERSECT and EXCEPT set operations are not "
|
|
||||||
"allowed in INSERT ... SELECT queries",
|
|
||||||
NULL, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1132,14 +1132,13 @@ SELECT
|
||||||
FROM
|
FROM
|
||||||
((SELECT user_id FROM raw_events_first) UNION
|
((SELECT user_id FROM raw_events_first) UNION
|
||||||
(SELECT user_id FROM raw_events_second)) as foo;
|
(SELECT user_id FROM raw_events_second)) as foo;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
|
||||||
-- We do not support any set operations
|
-- We do not support any set operations
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
raw_events_first(user_id)
|
raw_events_first(user_id)
|
||||||
(SELECT user_id FROM raw_events_first) INTERSECT
|
(SELECT user_id FROM raw_events_first) INTERSECT
|
||||||
(SELECT user_id FROM raw_events_first);
|
(SELECT user_id FROM raw_events_first);
|
||||||
ERROR: INTERSECT and EXCEPT set operations are not allowed in INSERT ... SELECT queries
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
-- We do not support any set operations
|
-- We do not support any set operations
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
raw_events_first(user_id)
|
raw_events_first(user_id)
|
||||||
|
@ -1148,7 +1147,7 @@ SELECT
|
||||||
FROM
|
FROM
|
||||||
((SELECT user_id FROM raw_events_first WHERE user_id = 15) EXCEPT
|
((SELECT user_id FROM raw_events_first WHERE user_id = 15) EXCEPT
|
||||||
(SELECT user_id FROM raw_events_second where user_id = 17)) as foo;
|
(SELECT user_id FROM raw_events_second where user_id = 17)) as foo;
|
||||||
ERROR: INTERSECT and EXCEPT set operations are not allowed in INSERT ... SELECT queries
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
-- some supported LEFT joins
|
-- some supported LEFT joins
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
@ -69,13 +69,9 @@ FROM (
|
||||||
) t2 ON (t1.user_id = t2.user_id)
|
) t2 ON (t1.user_id = t2.user_id)
|
||||||
GROUP BY t1.user_id, hasdone_event
|
GROUP BY t1.user_id, hasdone_event
|
||||||
) t GROUP BY user_id, hasdone_event;
|
) t GROUP BY user_id, hasdone_event;
|
||||||
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
-- SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
count | count | avg
|
|
||||||
-------+-------+---------------------
|
|
||||||
8 | 8 | 16.1250000000000000
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Funnel, grouped by the number of times a user has done an event
|
-- Funnel, grouped by the number of times a user has done an event
|
||||||
|
@ -147,13 +143,9 @@ GROUP BY
|
||||||
count_pay, user_id
|
count_pay, user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
count_pay;
|
count_pay;
|
||||||
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
-- SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
count | count | avg
|
|
||||||
-------+-------+---------------------
|
|
||||||
8 | 8 | 45.0000000000000000
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Most recently seen users_table events_table
|
-- Most recently seen users_table events_table
|
||||||
|
|
|
@ -101,6 +101,7 @@ FROM (
|
||||||
WHERE t1.user_id = 20
|
WHERE t1.user_id = 20
|
||||||
GROUP BY t1.user_id, hasdone_event
|
GROUP BY t1.user_id, hasdone_event
|
||||||
) t GROUP BY user_id, hasdone_event;
|
) t GROUP BY user_id, hasdone_event;
|
||||||
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Funnel grouped by whether or not a user has done an event -- two shards query
|
-- Funnel grouped by whether or not a user has done an event -- two shards query
|
||||||
|
@ -144,13 +145,9 @@ FROM (
|
||||||
WHERE (t1.user_id = 20 OR t1.user_id = 17)
|
WHERE (t1.user_id = 20 OR t1.user_id = 17)
|
||||||
GROUP BY t1.user_id, hasdone_event
|
GROUP BY t1.user_id, hasdone_event
|
||||||
) t GROUP BY user_id, hasdone_event;
|
) t GROUP BY user_id, hasdone_event;
|
||||||
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
-- SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
count | count | avg
|
|
||||||
-------+-------+---------------------
|
|
||||||
2 | 2 | 18.5000000000000000
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Most recently seen users_table events_table -- single shard query
|
-- Most recently seen users_table events_table -- single shard query
|
||||||
|
|
|
@ -66,8 +66,7 @@ FROM (
|
||||||
) t2 ON (t1.user_id = t2.user_id)
|
) t2 ON (t1.user_id = t2.user_id)
|
||||||
GROUP BY t1.user_id, hasdone_event
|
GROUP BY t1.user_id, hasdone_event
|
||||||
) t GROUP BY user_id, hasdone_event;
|
) t GROUP BY user_id, hasdone_event;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
|
||||||
-- not pushable since the JOIN is not an equi join right part of the UNION
|
-- not pushable since the JOIN is not an equi join right part of the UNION
|
||||||
-- is not joined on the partition key
|
-- is not joined on the partition key
|
||||||
INSERT INTO agg_results_third (user_id, value_1_agg, value_2_agg )
|
INSERT INTO agg_results_third (user_id, value_1_agg, value_2_agg )
|
||||||
|
@ -108,8 +107,7 @@ FROM (
|
||||||
) t2 ON (t1.user_id = t2.user_id)
|
) t2 ON (t1.user_id = t2.user_id)
|
||||||
GROUP BY t1.user_id, hasdone_event
|
GROUP BY t1.user_id, hasdone_event
|
||||||
) t GROUP BY user_id, hasdone_event;
|
) t GROUP BY user_id, hasdone_event;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
|
||||||
-- the LEFT JOIN conditon is not on the partition column (i.e., is it part_key divided by 2)
|
-- the LEFT JOIN conditon is not on the partition column (i.e., is it part_key divided by 2)
|
||||||
INSERT INTO agg_results_third (user_id, value_1_agg, value_2_agg )
|
INSERT INTO agg_results_third (user_id, value_1_agg, value_2_agg )
|
||||||
SELECT user_id, sum(array_length(events_table, 1)), length(hasdone_event)
|
SELECT user_id, sum(array_length(events_table, 1)), length(hasdone_event)
|
||||||
|
@ -149,8 +147,7 @@ FROM (
|
||||||
) t2 ON (t1.user_id = (t2.user_id)/2)
|
) t2 ON (t1.user_id = (t2.user_id)/2)
|
||||||
GROUP BY t1.user_id, hasdone_event
|
GROUP BY t1.user_id, hasdone_event
|
||||||
) t GROUP BY user_id, hasdone_event;
|
) t GROUP BY user_id, hasdone_event;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Funnel, grouped by the number of times a user has done an event
|
-- Funnel, grouped by the number of times a user has done an event
|
||||||
|
@ -223,8 +220,7 @@ GROUP BY
|
||||||
count_pay, user_id
|
count_pay, user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
count_pay;
|
count_pay;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
|
||||||
-- not pushable since the JOIN condition is not equi JOIN
|
-- not pushable since the JOIN condition is not equi JOIN
|
||||||
-- (subquery_1 JOIN subquery_2)
|
-- (subquery_1 JOIN subquery_2)
|
||||||
INSERT INTO agg_results_third (user_id, value_1_agg, value_2_agg)
|
INSERT INTO agg_results_third (user_id, value_1_agg, value_2_agg)
|
||||||
|
@ -292,8 +288,7 @@ GROUP BY
|
||||||
count_pay, user_id
|
count_pay, user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
count_pay;
|
count_pay;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: Set operations are not allowed in INSERT ... SELECT queries
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Most recently seen users_table events_table
|
-- Most recently seen users_table events_table
|
||||||
|
|
|
@ -71,7 +71,7 @@ FROM (
|
||||||
) t GROUP BY user_id, hasdone_event;
|
) t GROUP BY user_id, hasdone_event;
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
-- SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
@ -148,7 +148,7 @@ ORDER BY
|
||||||
count_pay;
|
count_pay;
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
-- SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
|
@ -146,7 +146,7 @@ FROM (
|
||||||
) t GROUP BY user_id, hasdone_event;
|
) t GROUP BY user_id, hasdone_event;
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
-- SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
|
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue