mirror of https://github.com/citusdata/citus.git
Merge pull request #335 from citusdata/check_count_distinct_on_single_subquery
Check count distinct on single subquerypull/337/head^2
commit
39b333996b
|
@ -259,6 +259,7 @@ MultiLogicalPlanOptimize(MultiTreeRoot *multiLogicalPlan)
|
|||
MultiTable *tableNode = (MultiTable *) lfirst(tableNodeCell);
|
||||
if (tableNode->relationId == SUBQUERY_RELATION_ID)
|
||||
{
|
||||
ErrorIfContainsUnsupportedAggregate((MultiNode *) tableNode);
|
||||
TransformSubqueryNode(tableNode);
|
||||
}
|
||||
}
|
||||
|
@ -2145,8 +2146,9 @@ ErrorIfUnsupportedAggregateDistinct(Aggref *aggregateExpression,
|
|||
bool distinctSupported = true;
|
||||
List *repartitionNodeList = NIL;
|
||||
Var *distinctColumn = NULL;
|
||||
|
||||
AggregateType aggregateType = GetAggregateType(aggregateExpression->aggfnoid);
|
||||
List *multiTableNodeList = NIL;
|
||||
ListCell *multiTableNodeCell = NULL;
|
||||
AggregateType aggregateType = AGGREGATE_INVALID_FIRST;
|
||||
|
||||
/* check if logical plan includes a subquery */
|
||||
List *subqueryMultiTableList = SubqueryMultiTableList(logicalPlanNode);
|
||||
|
@ -2157,7 +2159,20 @@ ErrorIfUnsupportedAggregateDistinct(Aggref *aggregateExpression,
|
|||
errdetail("distinct in the outermost query is unsupported")));
|
||||
}
|
||||
|
||||
multiTableNodeList = FindNodesOfType(logicalPlanNode, T_MultiTable);
|
||||
foreach(multiTableNodeCell, multiTableNodeList)
|
||||
{
|
||||
MultiTable *multiTable = (MultiTable *) lfirst(multiTableNodeCell);
|
||||
if (multiTable->relationId == SUBQUERY_RELATION_ID)
|
||||
{
|
||||
ereport(ERROR, (errmsg("cannot compute count (distinct)"),
|
||||
errdetail("Subqueries with aggregate (distinct) are "
|
||||
"not supported yet")));
|
||||
}
|
||||
}
|
||||
|
||||
/* if we have a count(distinct), and distinct approximation is enabled */
|
||||
aggregateType = GetAggregateType(aggregateExpression->aggfnoid);
|
||||
if (aggregateType == AGGREGATE_COUNT &&
|
||||
CountDistinctErrorRate != DISABLE_DISTINCT_APPROXIMATION)
|
||||
{
|
||||
|
|
|
@ -171,6 +171,18 @@ from
|
|||
l_tax) as distributed_table;
|
||||
ERROR: cannot perform distributed planning on this query
|
||||
DETAIL: Subqueries without aggregates are not supported yet
|
||||
-- Check that we don't support subqueries with count(distinct).
|
||||
select
|
||||
different_shipment_days
|
||||
from
|
||||
(select
|
||||
count(distinct l_shipdate) as different_shipment_days
|
||||
from
|
||||
lineitem
|
||||
group by
|
||||
l_partkey) as distributed_table;
|
||||
ERROR: cannot compute count (distinct)
|
||||
DETAIL: Subqueries with aggregate (distinct) are not supported yet
|
||||
-- Check that if subquery is pulled, we don't error and run query properly.
|
||||
SELECT max(l_suppkey) FROM
|
||||
(
|
||||
|
|
|
@ -125,6 +125,18 @@ from
|
|||
group by
|
||||
l_tax) as distributed_table;
|
||||
|
||||
-- Check that we don't support subqueries with count(distinct).
|
||||
|
||||
select
|
||||
different_shipment_days
|
||||
from
|
||||
(select
|
||||
count(distinct l_shipdate) as different_shipment_days
|
||||
from
|
||||
lineitem
|
||||
group by
|
||||
l_partkey) as distributed_table;
|
||||
|
||||
-- Check that if subquery is pulled, we don't error and run query properly.
|
||||
|
||||
SELECT max(l_suppkey) FROM
|
||||
|
|
Loading…
Reference in New Issue