mirror of https://github.com/citusdata/citus.git
Merge pull request #392 from citusdata/bugfix/#258-spurious-notice-message-with-any
Fix spurious NOTICE messages with ANY/ALLpull/415/head
commit
ac05e561ed
|
@ -2896,8 +2896,25 @@ HashableClauseMutator(Node *originalNode, Var *partitionColumn)
|
||||||
}
|
}
|
||||||
else if (IsA(originalNode, ScalarArrayOpExpr))
|
else if (IsA(originalNode, ScalarArrayOpExpr))
|
||||||
{
|
{
|
||||||
ereport(NOTICE, (errmsg("cannot use shard pruning with ANY (array expression)"),
|
ScalarArrayOpExpr *arrayOperatorExpression = (ScalarArrayOpExpr *) originalNode;
|
||||||
errhint("Consider rewriting the expression with OR clauses.")));
|
Node *leftOpExpression = linitial(arrayOperatorExpression->args);
|
||||||
|
Node *strippedLeftOpExpression = strip_implicit_coercions(leftOpExpression);
|
||||||
|
char *operatorName = get_opname(arrayOperatorExpression->opno);
|
||||||
|
int equalsCompare = strncmp(operatorName, EQUAL_OPERATOR_STRING, NAMEDATALEN);
|
||||||
|
bool usingEqualityOperator = (equalsCompare == 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Citus cannot prune hash-distributed shards with ANY/ALL. We show a NOTICE
|
||||||
|
* if the expression is ANY/ALL performed on the partition column with equality.
|
||||||
|
*/
|
||||||
|
if (usingEqualityOperator && strippedLeftOpExpression != NULL &&
|
||||||
|
equal(strippedLeftOpExpression, partitionColumn))
|
||||||
|
{
|
||||||
|
ereport(NOTICE, (errmsg("cannot use shard pruning with "
|
||||||
|
"ANY/ALL (array expression)"),
|
||||||
|
errhint("Consider rewriting the expression with "
|
||||||
|
"OR/AND clauses.")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -175,11 +175,30 @@ DEBUG: predicate pruning for shardId 111
|
||||||
explain statements for distributed queries are currently unsupported
|
explain statements for distributed queries are currently unsupported
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- Check that we don't support pruning for ANY (array expression)
|
-- Check that we don't support pruning for ANY (array expression) and give
|
||||||
|
-- a notice message when used with the partition column
|
||||||
|
EXPLAIN SELECT count(*) FROM orders_hash_partitioned
|
||||||
|
WHERE o_orderkey = ANY ('{1,2,3}');
|
||||||
|
NOTICE: cannot use shard pruning with ANY/ALL (array expression)
|
||||||
|
HINT: Consider rewriting the expression with OR/AND clauses.
|
||||||
|
QUERY PLAN
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
explain statements for distributed queries are currently unsupported
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Check that we don't show the message if the operator is not
|
||||||
|
-- equality operator
|
||||||
|
EXPLAIN SELECT count(*) FROM orders_hash_partitioned
|
||||||
|
WHERE o_orderkey < ALL ('{1,2,3}');
|
||||||
|
QUERY PLAN
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
explain statements for distributed queries are currently unsupported
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Check that we don't give a spurious hint message when non-partition
|
||||||
|
-- columns are used with ANY/IN/ALL
|
||||||
EXPLAIN SELECT count(*) FROM orders_hash_partitioned
|
EXPLAIN SELECT count(*) FROM orders_hash_partitioned
|
||||||
WHERE o_orderkey = 1 OR o_totalprice IN (2, 5);
|
WHERE o_orderkey = 1 OR o_totalprice IN (2, 5);
|
||||||
NOTICE: cannot use shard pruning with ANY (array expression)
|
|
||||||
HINT: Consider rewriting the expression with OR clauses.
|
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
explain statements for distributed queries are currently unsupported
|
explain statements for distributed queries are currently unsupported
|
||||||
|
|
|
@ -91,8 +91,18 @@ EXPLAIN SELECT count(*) FROM
|
||||||
|
|
||||||
EXPLAIN SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = abs(-1);
|
EXPLAIN SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = abs(-1);
|
||||||
|
|
||||||
-- Check that we don't support pruning for ANY (array expression)
|
-- Check that we don't support pruning for ANY (array expression) and give
|
||||||
|
-- a notice message when used with the partition column
|
||||||
|
EXPLAIN SELECT count(*) FROM orders_hash_partitioned
|
||||||
|
WHERE o_orderkey = ANY ('{1,2,3}');
|
||||||
|
|
||||||
|
-- Check that we don't show the message if the operator is not
|
||||||
|
-- equality operator
|
||||||
|
EXPLAIN SELECT count(*) FROM orders_hash_partitioned
|
||||||
|
WHERE o_orderkey < ALL ('{1,2,3}');
|
||||||
|
|
||||||
|
-- Check that we don't give a spurious hint message when non-partition
|
||||||
|
-- columns are used with ANY/IN/ALL
|
||||||
EXPLAIN SELECT count(*) FROM orders_hash_partitioned
|
EXPLAIN SELECT count(*) FROM orders_hash_partitioned
|
||||||
WHERE o_orderkey = 1 OR o_totalprice IN (2, 5);
|
WHERE o_orderkey = 1 OR o_totalprice IN (2, 5);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue