From 2cbebc1c00add3ecd45c8baf1ceae3a395d82225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Kalac=C4=B1?= Date: Mon, 24 Apr 2017 16:35:07 +0300 Subject: [PATCH] Fix merge conflicts (#1347) - Update regression tests to meet the changes in the regression test output. - Replace Ifs with Asserts given that the check is already done - Update shard pruning outputs --- .../planner/multi_logical_optimizer.c | 33 +------ .../multi_subquery_behavioral_analytics.out | 4 +- src/test/regress/input/multi_subquery.source | 2 + src/test/regress/output/multi_subquery.source | 99 +++++++------------ .../regress/output/multi_subquery_0.source | 82 ++++++--------- 5 files changed, 74 insertions(+), 146 deletions(-) diff --git a/src/backend/distributed/planner/multi_logical_optimizer.c b/src/backend/distributed/planner/multi_logical_optimizer.c index d27173a4a..c32bbe7a0 100644 --- a/src/backend/distributed/planner/multi_logical_optimizer.c +++ b/src/backend/distributed/planner/multi_logical_optimizer.c @@ -2977,24 +2977,6 @@ FindReferencedTableColumn(Expr *columnExpression, List *parentQueryList, Query * /* - * CoPartitionedTables checks if given two distributed tables have 1-to-1 - * shard partitioning. - /* - * Check if the tables have the same colocation ID - if so, we know - * they're colocated. - */ - if (firstTableCache->colocationId != INVALID_COLOCATION_ID && - firstTableCache->colocationId == secondTableCache->colocationId) - { - return true; - } - - /* - * If not known to be colocated check if the remaining shards are - * anyway. Do so by comparing the shard interval arrays that are sorted on - * interval minimum values. Then it compares every shard interval in order - * and if any pair of shard intervals are not equal it returns false. - */ * ExtractQueryWalker walks over a query, and finds all queries in the query * tree and returns these queries. */ @@ -3237,18 +3219,9 @@ WorkerLimitCount(MultiExtendedOp *originalOpNode) * certain expressions such as parameters are not evaluated and converted * into Consts on the op node. */ - if (!IsA(originalOpNode->limitCount, Const)) - { - ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("unsupported limit clause"))); - } - - /* same as the above but this time for OFFSET clause */ - if (originalOpNode->limitOffset && !IsA(originalOpNode->limitOffset, Const)) - { - ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("unsupported offset clause"))); - } + Assert(IsA(originalOpNode->limitCount, Const)); + Assert(originalOpNode->limitOffset == NULL || + IsA(originalOpNode->limitOffset, Const)); /* * If we don't have group by clauses, or if we have order by clauses without diff --git a/src/test/regress/expected/multi_subquery_behavioral_analytics.out b/src/test/regress/expected/multi_subquery_behavioral_analytics.out index 35c6a0919..4340d115b 100644 --- a/src/test/regress/expected/multi_subquery_behavioral_analytics.out +++ b/src/test/regress/expected/multi_subquery_behavioral_analytics.out @@ -1930,7 +1930,7 @@ FROM ( ORDER BY 2 DESC, 1 LIMIT $1 OFFSET $2; EXECUTE parametrized_limit(3,3); -ERROR: unsupported limit clause +ERROR: no value found for parameter 1 PREPARE parametrized_offset AS SELECT user_id, array_length(events_table, 1) FROM ( @@ -1947,7 +1947,7 @@ FROM ( ORDER BY 2 DESC, 1 LIMIT 3 OFFSET $1; EXECUTE parametrized_offset(3); -ERROR: unsupported offset clause +ERROR: no value found for parameter 1 SET client_min_messages TO DEFAULT; DROP FUNCTION volatile_func_test(); SET citus.subquery_pushdown to OFF; diff --git a/src/test/regress/input/multi_subquery.source b/src/test/regress/input/multi_subquery.source index 757147571..d5eb0fc64 100644 --- a/src/test/regress/input/multi_subquery.source +++ b/src/test/regress/input/multi_subquery.source @@ -1329,6 +1329,8 @@ ORDER BY count_pay; -- Lateral join subquery pushdown +-- set subquery_pushdown due to limit in the query +SET citus.subquery_pushdown to ON; EXPLAIN (COSTS OFF) SELECT tenant_id, diff --git a/src/test/regress/output/multi_subquery.source b/src/test/regress/output/multi_subquery.source index 051c9af62..90108bebc 100644 --- a/src/test/regress/output/multi_subquery.source +++ b/src/test/regress/output/multi_subquery.source @@ -407,20 +407,8 @@ SET client_min_messages TO DEBUG2; SELECT * FROM (SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE a = 'onder' GROUP BY a) AS foo; -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270005 because SELECT query is pruned away for the interval -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270006 because SELECT query is pruned away for the interval -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270008 because SELECT query is pruned away for the interval count ------- @@ -429,20 +417,8 @@ DEBUG: Skipping the target shard interval 270008 because SELECT query is pruned SELECT * FROM (SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE 'eren' = a GROUP BY a) AS foo; -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270005 because SELECT query is pruned away for the interval -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270007 because SELECT query is pruned away for the interval -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270008 because SELECT query is pruned away for the interval count ------- @@ -1202,15 +1178,14 @@ FROM -> Aggregate -> GroupAggregate Group Key: (((NULL::user_composite_type)).tenant_id), (((NULL::user_composite_type)).user_id) - -> Merge Join + -> Sort Sort Key: (((NULL::user_composite_type)).tenant_id), (((NULL::user_composite_type)).user_id) - -> Sort + -> Hash Join Hash Cond: ((NULL::user_composite_type) = events.composite_id) - -> Seq Scan on users_270013 users + -> Result One-Time Filter: false - -> Sort - -> Seq Scan on events_270011 events (cost=0.00..11.79 rows=3 width=556) - -> Seq Scan on events_270009 events + -> Hash + -> Seq Scan on events_270011 events Filter: ((event_type)::text = ANY ('{click,submit,pay}'::text[])) (18 rows) @@ -1279,46 +1254,46 @@ GROUP BY hasdone; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -x HashAggregate + HashAggregate + Group Key: remote_scan.hasdone -> Custom Scan (Citus Real-Time) + Task Count: 4 + Tasks Shown: One of 4 + -> Task + Node: host=localhost port=57637 dbname=regression -> GroupAggregate + Group Key: subquery_top.hasdone -> Sort + Sort Key: subquery_top.hasdone -> Subquery Scan on subquery_top -> GroupAggregate + Group Key: subquery_1.tenant_id, subquery_1.user_id, ('Has done paying'::text) -> Sort - -> Merge Left Join + Sort Key: subquery_1.tenant_id, subquery_1.user_id, ('Has done paying'::text) + -> Hash Right Join + Hash Cond: (events.composite_id = subquery_1.composite_id) -> Unique -> Sort - -> Append - -> Nested Loop - -> Seq Scan on events_270009 events - -> Seq Scan on users_270013 users - -> Nested Loop - -> Seq Scan on events_270009 events_1 - -> Seq Scan on users_270013 users_1 - -> Materialize - -> Unique - -> Sort - -> Seq Scan on events_270009 events_2 - -> Seq Scan on events_270011 events (cost=0.00..76.62 rows=1 width=80) + Sort Key: ((events.composite_id).tenant_id), ((events.composite_id).user_id) + -> Seq Scan on events_270011 events Filter: (((event_type)::text = 'pay'::text) AND (composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type)) - -> Hash (cost=23.89..23.89 rows=2 width=88) - -> Subquery Scan on subquery_1 (cost=23.84..23.89 rows=2 width=88) - -> Unique (cost=23.84..23.87 rows=2 width=88) - -> Sort (cost=23.84..23.84 rows=2 width=88) + -> Hash + -> Subquery Scan on subquery_1 + -> Unique + -> Sort Sort Key: (((NULL::user_composite_type)).tenant_id), (((NULL::user_composite_type)).user_id), (NULL::user_composite_type), ('action=>1'::text), events_1.event_time - -> Append (cost=0.00..23.83 rows=2 width=88) - -> Nested Loop (cost=0.00..11.90 rows=1 width=88) + -> Append + -> Nested Loop Join Filter: ((NULL::user_composite_type) = events_1.composite_id) - -> Result (cost=0.00..0.01 rows=1 width=40) + -> Result One-Time Filter: false - -> Seq Scan on events_270011 events_1 (cost=0.00..11.62 rows=1 width=40) + -> Seq Scan on events_270011 events_1 Filter: ((event_type)::text = 'click'::text) - -> Nested Loop (cost=0.00..11.90 rows=1 width=88) + -> Nested Loop Join Filter: ((NULL::user_composite_type) = events_2.composite_id) - -> Result (cost=0.00..0.01 rows=1 width=40) + -> Result One-Time Filter: false - -> Seq Scan on events_270011 events_2 (cost=0.00..11.62 rows=1 width=40) + -> Seq Scan on events_270011 events_2 Filter: ((event_type)::text = 'submit'::text) (41 rows) @@ -1395,6 +1370,8 @@ ORDER BY count_pay; ERROR: bogus varattno for OUTER_VAR var: 3 -- Lateral join subquery pushdown +-- set subquery_pushdown due to limit in the query +SET citus.subquery_pushdown to ON; EXPLAIN (COSTS OFF) SELECT tenant_id, @@ -1445,8 +1422,8 @@ ORDER BY user_lastseen DESC LIMIT 10; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------ Limit -> Sort Sort Key: remote_scan.user_lastseen DESC @@ -1466,13 +1443,13 @@ LIMIT -> Limit -> Sort Sort Key: users.lastseen DESC - -> Seq Scan on users_270013 users - -> Result (cost=0.00..0.01 rows=1 width=40) + -> Subquery Scan on users + -> Result + One-Time Filter: false -> Limit -> Sort - -> Sort (cost=43.81..43.82 rows=1 width=524) Sort Key: events.event_time DESC - -> Seq Scan on events_270009 events + -> Seq Scan on events_270011 events Filter: (composite_id = users.composite_id) (27 rows) diff --git a/src/test/regress/output/multi_subquery_0.source b/src/test/regress/output/multi_subquery_0.source index dcdc95a99..8e86ed404 100644 --- a/src/test/regress/output/multi_subquery_0.source +++ b/src/test/regress/output/multi_subquery_0.source @@ -407,20 +407,8 @@ SET client_min_messages TO DEBUG2; SELECT * FROM (SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE a = 'onder' GROUP BY a) AS foo; -DEBUG: predicate pruning for shardId 270007 DEBUG: Skipping the target shard interval 270005 because SELECT query is pruned away for the interval -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270006 because SELECT query is pruned away for the interval -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270008 -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270008 because SELECT query is pruned away for the interval count ------- @@ -429,20 +417,8 @@ DEBUG: Skipping the target shard interval 270008 because SELECT query is pruned SELECT * FROM (SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE 'eren' = a GROUP BY a) AS foo; -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270005 because SELECT query is pruned away for the interval -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 -DEBUG: predicate pruning for shardId 270007 -DEBUG: predicate pruning for shardId 270008 DEBUG: Skipping the target shard interval 270007 because SELECT query is pruned away for the interval -DEBUG: predicate pruning for shardId 270005 -DEBUG: predicate pruning for shardId 270006 DEBUG: Skipping the target shard interval 270008 because SELECT query is pruned away for the interval count ------- @@ -1199,16 +1175,14 @@ FROM Tasks Shown: One of 4 -> Task Node: host=localhost port=57637 dbname=regression - -> Aggregate + -> Aggregate -> GroupAggregate Group Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id) - -> Merge Join - -> Sort + -> Sort Sort Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id) - -> Seq Scan on users_270013 users + -> Result One-Time Filter: false - -> Sort - -> Seq Scan on events_270009 events +(13 rows) -- Union and left join subquery pushdown EXPLAIN (COSTS OFF) @@ -1276,34 +1250,34 @@ GROUP BY QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- HashAggregate + Group Key: remote_scan.hasdone -> Custom Scan (Citus Real-Time) + Task Count: 4 + Tasks Shown: One of 4 + -> Task + Node: host=localhost port=57637 dbname=regression -> HashAggregate + Group Key: COALESCE(('Has done paying'::text), 'Has not done paying'::text) -> GroupAggregate + Group Key: subquery_1.tenant_id, subquery_1.user_id, ('Has done paying'::text) -> Sort - -> Merge Left Join + Sort Key: subquery_1.tenant_id, subquery_1.user_id, ('Has done paying'::text) + -> Hash Right Join + Hash Cond: (events.composite_id = subquery_1.composite_id) -> Unique -> Sort - -> Append - -> Nested Loop - -> Seq Scan on events_270009 events - -> Seq Scan on users_270013 users - -> Nested Loop - -> Seq Scan on events_270009 events_1 - -> Seq Scan on users_270013 users_1 - -> Materialize - -> Unique - -> Sort - -> Seq Scan on events_270009 events_2 + Sort Key: ((events.composite_id).tenant_id), ((events.composite_id).user_id) + -> Seq Scan on events_270011 events Filter: (((event_type)::text = 'pay'::text) AND (composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type)) - -> Hash (cost=0.10..0.10 rows=2 width=88) - -> Subquery Scan on subquery_1 (cost=0.05..0.10 rows=2 width=88) - -> Unique (cost=0.05..0.08 rows=2 width=0) - -> Sort (cost=0.05..0.06 rows=2 width=0) + -> Hash + -> Subquery Scan on subquery_1 + -> Unique + -> Sort Sort Key: ((composite_id).tenant_id), ((composite_id).user_id), composite_id, ('action=>1'::text), event_time - -> Append (cost=0.00..0.04 rows=2 width=0) - -> Result (cost=0.00..0.01 rows=1 width=0) + -> Append + -> Result One-Time Filter: false - -> Result (cost=0.00..0.01 rows=1 width=0) + -> Result One-Time Filter: false (30 rows) @@ -1380,6 +1354,8 @@ ORDER BY count_pay; ERROR: bogus varattno for OUTER_VAR var: 3 -- Lateral join subquery pushdown +-- set subquery_pushdown due to limit in the query +SET citus.subquery_pushdown to ON; EXPLAIN (COSTS OFF) SELECT tenant_id, @@ -1430,8 +1406,8 @@ ORDER BY user_lastseen DESC LIMIT 10; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ + QUERY PLAN +------------------------------------------------------------------------------------------------------------ Limit -> Sort Sort Key: remote_scan.user_lastseen DESC @@ -1451,12 +1427,12 @@ LIMIT -> Limit -> Sort Sort Key: lastseen DESC - -> Seq Scan on users_270013 users + -> Result One-Time Filter: false -> Limit -> Sort Sort Key: events.event_time DESC - -> Seq Scan on events_270009 events + -> Seq Scan on events_270011 events Filter: (composite_id = composite_id) (26 rows)