mirror of https://github.com/citusdata/citus.git
Adjust the existing regression tests
parent
7a4d6b2984
commit
82a4830c7d
|
@ -21,6 +21,13 @@
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
|
#include "distributed/pg_version_constants.h"
|
||||||
|
|
||||||
|
#if PG_VERSION_NUM >= PG_VERSION_12
|
||||||
|
#include "access/relation.h"
|
||||||
|
#else
|
||||||
|
#include "access/heapam.h"
|
||||||
|
#endif
|
||||||
#include "distributed/multi_logical_planner.h"
|
#include "distributed/multi_logical_planner.h"
|
||||||
#include "distributed/query_colocation_checker.h"
|
#include "distributed/query_colocation_checker.h"
|
||||||
#include "distributed/pg_dist_partition.h"
|
#include "distributed/pg_dist_partition.h"
|
||||||
|
@ -269,7 +276,6 @@ WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation)
|
||||||
newRangeTableRef->rtindex = 1;
|
newRangeTableRef->rtindex = 1;
|
||||||
subquery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL);
|
subquery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL);
|
||||||
|
|
||||||
|
|
||||||
Relation relation = relation_open(rteRelation->relid, AccessShareLock);
|
Relation relation = relation_open(rteRelation->relid, AccessShareLock);
|
||||||
int numberOfAttributes = RelationGetNumberOfAttributes(relation);
|
int numberOfAttributes = RelationGetNumberOfAttributes(relation);
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@
|
||||||
#else
|
#else
|
||||||
#include "optimizer/cost.h"
|
#include "optimizer/cost.h"
|
||||||
#include "nodes/relation.h"
|
#include "nodes/relation.h"
|
||||||
|
#include "optimizer/var.h"
|
||||||
#endif
|
#endif
|
||||||
#include "optimizer/paths.h"
|
#include "optimizer/paths.h"
|
||||||
#include "optimizer/var.h"
|
|
||||||
#include "parser/parsetree.h"
|
#include "parser/parsetree.h"
|
||||||
#include "optimizer/pathnode.h"
|
#include "optimizer/pathnode.h"
|
||||||
|
|
||||||
|
@ -1879,14 +1879,9 @@ GetRestrictInfoListForRelation(RangeTblEntry *rangeTblEntry,
|
||||||
{
|
{
|
||||||
RestrictInfo *restrictInfo = (RestrictInfo *) lfirst(restrictCell);
|
RestrictInfo *restrictInfo = (RestrictInfo *) lfirst(restrictCell);
|
||||||
Expr *restrictionClause = restrictInfo->clause;
|
Expr *restrictionClause = restrictInfo->clause;
|
||||||
List *varClauses = NIL;
|
|
||||||
ListCell *varClauseCell = NULL;
|
|
||||||
Relids varnos = NULL;
|
|
||||||
|
|
||||||
Expr *copyOfRestrictClause = NULL;
|
|
||||||
|
|
||||||
/* we cannot process Params beacuse they are not known at this point */
|
/* we cannot process Params beacuse they are not known at this point */
|
||||||
if (FindNodeCheck((Node *) restrictionClause, IsParam))
|
if (FindNodeMatchingCheckFunction((Node *) restrictionClause, IsParam))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1895,7 +1890,7 @@ GetRestrictInfoListForRelation(RangeTblEntry *rangeTblEntry,
|
||||||
* If the restriction involves multiple tables, we cannot add it to
|
* If the restriction involves multiple tables, we cannot add it to
|
||||||
* input relation's expression list.
|
* input relation's expression list.
|
||||||
*/
|
*/
|
||||||
varnos = pull_varnos((Node *) restrictionClause);
|
Relids varnos = pull_varnos((Node *) restrictionClause);
|
||||||
if (bms_num_members(varnos) != 1)
|
if (bms_num_members(varnos) != 1)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -1906,14 +1901,15 @@ GetRestrictInfoListForRelation(RangeTblEntry *rangeTblEntry,
|
||||||
* which consists of only one relation in its jointree. Thus,
|
* which consists of only one relation in its jointree. Thus,
|
||||||
* simply set the varnos accordingly.
|
* simply set the varnos accordingly.
|
||||||
*/
|
*/
|
||||||
copyOfRestrictClause = (Expr *) copyObject((Node *) restrictionClause);
|
Expr *copyOfRestrictClause = (Expr *) copyObject((Node *) restrictionClause);
|
||||||
varClauses = pull_var_clause_default((Node *) copyOfRestrictClause);
|
List *varClauses = pull_var_clause_default((Node *) copyOfRestrictClause);
|
||||||
|
ListCell *varClauseCell = NULL;
|
||||||
foreach(varClauseCell, varClauses)
|
foreach(varClauseCell, varClauses)
|
||||||
{
|
{
|
||||||
Var *column = (Var *) lfirst(varClauseCell);
|
Var *column = (Var *) lfirst(varClauseCell);
|
||||||
|
|
||||||
column->varno = rteIndex;
|
column->varno = rteIndex;
|
||||||
column->varnoold = rteIndex;
|
column->varnosyn = rteIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
restrictExprList = lappend(restrictExprList, copyOfRestrictClause);
|
restrictExprList = lappend(restrictExprList, copyOfRestrictClause);
|
||||||
|
|
|
@ -417,12 +417,22 @@ HINT: To remove the local data, run: SELECT truncate_local_data_after_distribut
|
||||||
|
|
||||||
INSERT INTO dist_table VALUES(1);
|
INSERT INTO dist_table VALUES(1);
|
||||||
NOTICE: executing the command locally: INSERT INTO coordinator_shouldhaveshards.dist_table_1503017 (a) VALUES (1)
|
NOTICE: executing the command locally: INSERT INTO coordinator_shouldhaveshards.dist_table_1503017 (a) VALUES (1)
|
||||||
SELECT * FROM local JOIN dist_table ON (a = x);
|
SELECT * FROM local JOIN dist_table ON (a = x) ORDER BY 1,2,3;
|
||||||
ERROR: direct joins between distributed and local tables are not supported
|
x | y | a
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
---------------------------------------------------------------------
|
||||||
SELECT * FROM local JOIN dist_table ON (a = x) WHERE a = 1;;
|
1 | 2 | 1
|
||||||
ERROR: direct joins between distributed and local tables are not supported
|
1 | 2 | 1
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
3 | 2 | 3
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SELECT * FROM local JOIN dist_table ON (a = x) WHERE a = 1 ORDER BY 1,2,3;
|
||||||
|
NOTICE: executing the command locally: SELECT local.x, local.y, dist_table.a FROM ((SELECT intermediate_result.x, intermediate_result.y FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(x integer, y integer)) local JOIN coordinator_shouldhaveshards.dist_table_1503017 dist_table ON ((dist_table.a OPERATOR(pg_catalog.=) local.x))) WHERE (dist_table.a OPERATOR(pg_catalog.=) 1) ORDER BY local.x, local.y, dist_table.a
|
||||||
|
x | y | a
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1 | 2 | 1
|
||||||
|
1 | 2 | 1
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
-- intermediate results are allowed
|
-- intermediate results are allowed
|
||||||
WITH cte_1 AS (SELECT * FROM dist_table ORDER BY 1 LIMIT 1)
|
WITH cte_1 AS (SELECT * FROM dist_table ORDER BY 1 LIMIT 1)
|
||||||
SELECT * FROM ref JOIN local ON (a = x) JOIN cte_1 ON (local.x = cte_1.a);
|
SELECT * FROM ref JOIN local ON (a = x) JOIN cte_1 ON (local.x = cte_1.a);
|
||||||
|
|
|
@ -340,8 +340,10 @@ FROM cte_1
|
||||||
WHERE distributed_table.tenant_id < cte_1.tenant_id;
|
WHERE distributed_table.tenant_id < cte_1.tenant_id;
|
||||||
DEBUG: generating subplan XXX_1 for CTE cte_1: WITH cte_2 AS (SELECT second_distributed_table.tenant_id AS cte2_id FROM recursive_dml_queries.second_distributed_table WHERE (second_distributed_table.dept OPERATOR(pg_catalog.>=) 2)) UPDATE recursive_dml_queries.distributed_table SET dept = 10 RETURNING tenant_id, dept, info
|
DEBUG: generating subplan XXX_1 for CTE cte_1: WITH cte_2 AS (SELECT second_distributed_table.tenant_id AS cte2_id FROM recursive_dml_queries.second_distributed_table WHERE (second_distributed_table.dept OPERATOR(pg_catalog.>=) 2)) UPDATE recursive_dml_queries.distributed_table SET dept = 10 RETURNING tenant_id, dept, info
|
||||||
DEBUG: Plan XXX query after replacing subqueries and CTEs: UPDATE recursive_dml_queries.distributed_table SET dept = 5 FROM (SELECT intermediate_result.tenant_id, intermediate_result.dept, intermediate_result.info FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text, dept integer, info jsonb)) cte_1 WHERE (distributed_table.tenant_id OPERATOR(pg_catalog.<) cte_1.tenant_id)
|
DEBUG: Plan XXX query after replacing subqueries and CTEs: UPDATE recursive_dml_queries.distributed_table SET dept = 5 FROM (SELECT intermediate_result.tenant_id, intermediate_result.dept, intermediate_result.info FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text, dept integer, info jsonb)) cte_1 WHERE (distributed_table.tenant_id OPERATOR(pg_catalog.<) cte_1.tenant_id)
|
||||||
-- we don't support updating local table with a join with
|
-- we support updating local table with a join with
|
||||||
-- distributed tables
|
-- distributed tables, though as the local table
|
||||||
|
-- is target here, distributed table is recursively
|
||||||
|
-- planned
|
||||||
UPDATE
|
UPDATE
|
||||||
local_table
|
local_table
|
||||||
SET
|
SET
|
||||||
|
@ -350,8 +352,9 @@ FROM
|
||||||
distributed_table
|
distributed_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.tenant_id = local_table.id;
|
distributed_table.tenant_id = local_table.id;
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
DEBUG: Wrapping local relation "distributed_table" to a subquery: SELECT tenant_id, dept, info FROM recursive_dml_queries.distributed_table WHERE true OFFSET 0
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
DEBUG: generating subplan XXX_1 for subquery SELECT tenant_id, dept, info FROM recursive_dml_queries.distributed_table WHERE true OFFSET 0
|
||||||
|
DEBUG: Plan XXX query after replacing subqueries and CTEs: UPDATE recursive_dml_queries.local_table SET id = 'citus_test'::text FROM (SELECT intermediate_result.tenant_id, intermediate_result.dept, intermediate_result.info FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text, dept integer, info jsonb)) distributed_table WHERE (distributed_table.tenant_id OPERATOR(pg_catalog.=) local_table.id)
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
DROP SCHEMA recursive_dml_queries CASCADE;
|
DROP SCHEMA recursive_dml_queries CASCADE;
|
||||||
NOTICE: drop cascades to 5 other objects
|
NOTICE: drop cascades to 5 other objects
|
||||||
|
|
|
@ -270,8 +270,6 @@ CREATE TABLE bidders ( name text, id bigint );
|
||||||
DELETE FROM limit_orders USING bidders WHERE limit_orders.id = 246 AND
|
DELETE FROM limit_orders USING bidders WHERE limit_orders.id = 246 AND
|
||||||
limit_orders.bidder_id = bidders.id AND
|
limit_orders.bidder_id = bidders.id AND
|
||||||
bidders.name = 'Bernie Madoff';
|
bidders.name = 'Bernie Madoff';
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
|
||||||
-- commands containing a CTE are supported
|
-- commands containing a CTE are supported
|
||||||
WITH new_orders AS (INSERT INTO limit_orders VALUES (411, 'FLO', 12, '2017-07-02 16:32:15', 'buy', 66))
|
WITH new_orders AS (INSERT INTO limit_orders VALUES (411, 'FLO', 12, '2017-07-02 16:32:15', 'buy', 66))
|
||||||
DELETE FROM limit_orders WHERE id < 0;
|
DELETE FROM limit_orders WHERE id < 0;
|
||||||
|
@ -429,13 +427,11 @@ ERROR: modifying the partition value of rows is not allowed
|
||||||
UPDATE limit_orders SET id = 246 WHERE id = 246;
|
UPDATE limit_orders SET id = 246 WHERE id = 246;
|
||||||
UPDATE limit_orders SET id = 246 WHERE id = 246 AND symbol = 'GM';
|
UPDATE limit_orders SET id = 246 WHERE id = 246 AND symbol = 'GM';
|
||||||
UPDATE limit_orders SET id = limit_orders.id WHERE id = 246;
|
UPDATE limit_orders SET id = limit_orders.id WHERE id = 246;
|
||||||
-- UPDATEs with a FROM clause are unsupported
|
-- UPDATEs with a FROM clause are supported even with local tables
|
||||||
UPDATE limit_orders SET limit_price = 0.00 FROM bidders
|
UPDATE limit_orders SET limit_price = 0.00 FROM bidders
|
||||||
WHERE limit_orders.id = 246 AND
|
WHERE limit_orders.id = 246 AND
|
||||||
limit_orders.bidder_id = bidders.id AND
|
limit_orders.bidder_id = bidders.id AND
|
||||||
bidders.name = 'Bernie Madoff';
|
bidders.name = 'Bernie Madoff';
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
|
||||||
-- should succeed with a CTE
|
-- should succeed with a CTE
|
||||||
WITH deleted_orders AS (INSERT INTO limit_orders VALUES (399, 'PDR', 14, '2017-07-02 16:32:15', 'sell', 43))
|
WITH deleted_orders AS (INSERT INTO limit_orders VALUES (399, 'PDR', 14, '2017-07-02 16:32:15', 'sell', 43))
|
||||||
UPDATE limit_orders SET symbol = 'GM';
|
UPDATE limit_orders SET symbol = 'GM';
|
||||||
|
@ -1306,7 +1302,8 @@ DELETE FROM summary_table WHERE id < (
|
||||||
);
|
);
|
||||||
CREATE TABLE multi_modifications.local (a int default 1, b int);
|
CREATE TABLE multi_modifications.local (a int default 1, b int);
|
||||||
INSERT INTO multi_modifications.local VALUES (default, (SELECT min(id) FROM summary_table));
|
INSERT INTO multi_modifications.local VALUES (default, (SELECT min(id) FROM summary_table));
|
||||||
ERROR: cannot plan modifications of local tables involving distributed tables
|
ERROR: subqueries are not supported within INSERT queries
|
||||||
|
HINT: Try rewriting your queries with 'INSERT INTO ... SELECT' syntax.
|
||||||
DROP TABLE raw_table;
|
DROP TABLE raw_table;
|
||||||
DROP TABLE summary_table;
|
DROP TABLE summary_table;
|
||||||
DROP TABLE reference_raw_table;
|
DROP TABLE reference_raw_table;
|
||||||
|
|
|
@ -158,7 +158,6 @@ CREATE TABLE bidders ( name text, id bigint );
|
||||||
DELETE FROM limit_orders_mx USING bidders WHERE limit_orders_mx.id = 246 AND
|
DELETE FROM limit_orders_mx USING bidders WHERE limit_orders_mx.id = 246 AND
|
||||||
limit_orders_mx.bidder_id = bidders.id AND
|
limit_orders_mx.bidder_id = bidders.id AND
|
||||||
bidders.name = 'Bernie Madoff';
|
bidders.name = 'Bernie Madoff';
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
|
||||||
-- commands containing a CTE are supported
|
-- commands containing a CTE are supported
|
||||||
WITH new_orders AS (INSERT INTO limit_orders_mx VALUES (411, 'FLO', 12, '2017-07-02 16:32:15', 'buy', 66))
|
WITH new_orders AS (INSERT INTO limit_orders_mx VALUES (411, 'FLO', 12, '2017-07-02 16:32:15', 'buy', 66))
|
||||||
DELETE FROM limit_orders_mx WHERE id < 0;
|
DELETE FROM limit_orders_mx WHERE id < 0;
|
||||||
|
@ -225,7 +224,6 @@ UPDATE limit_orders_mx SET limit_price = 0.00 FROM bidders
|
||||||
WHERE limit_orders_mx.id = 246 AND
|
WHERE limit_orders_mx.id = 246 AND
|
||||||
limit_orders_mx.bidder_id = bidders.id AND
|
limit_orders_mx.bidder_id = bidders.id AND
|
||||||
bidders.name = 'Bernie Madoff';
|
bidders.name = 'Bernie Madoff';
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
|
||||||
-- commands containing a CTE are supported
|
-- commands containing a CTE are supported
|
||||||
WITH deleted_orders AS (INSERT INTO limit_orders_mx VALUES (399, 'PDR', 14, '2017-07-02 16:32:15', 'sell', 43))
|
WITH deleted_orders AS (INSERT INTO limit_orders_mx VALUES (399, 'PDR', 14, '2017-07-02 16:32:15', 'sell', 43))
|
||||||
UPDATE limit_orders_mx SET symbol = 'GM';
|
UPDATE limit_orders_mx SET symbol = 'GM';
|
||||||
|
|
|
@ -72,8 +72,11 @@ CREATE TABLE temp_nations(name text, key integer);
|
||||||
SELECT master_modify_multiple_shards('DELETE FROM multi_shard_modify_test USING temp_nations WHERE multi_shard_modify_test.t_value = temp_nations.key AND temp_nations.name = ''foobar'' ');
|
SELECT master_modify_multiple_shards('DELETE FROM multi_shard_modify_test USING temp_nations WHERE multi_shard_modify_test.t_value = temp_nations.key AND temp_nations.name = ''foobar'' ');
|
||||||
WARNING: master_modify_multiple_shards is deprecated and will be removed in a future release.
|
WARNING: master_modify_multiple_shards is deprecated and will be removed in a future release.
|
||||||
HINT: Run the command directly
|
HINT: Run the command directly
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
master_modify_multiple_shards
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
---------------------------------------------------------------------
|
||||||
|
0
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- commands with a USING clause are unsupported
|
-- commands with a USING clause are unsupported
|
||||||
SELECT create_distributed_table('temp_nations', 'name', 'hash');
|
SELECT create_distributed_table('temp_nations', 'name', 'hash');
|
||||||
create_distributed_table
|
create_distributed_table
|
||||||
|
|
|
@ -730,19 +730,15 @@ SET value_2 = subquery.random FROM (SELECT user_id, random()
|
||||||
WHERE users_test_table.user_id = subquery.user_id;
|
WHERE users_test_table.user_id = subquery.user_id;
|
||||||
-- Make following tests consistent
|
-- Make following tests consistent
|
||||||
UPDATE users_test_table SET value_2 = 0;
|
UPDATE users_test_table SET value_2 = 0;
|
||||||
-- Local tables are not supported
|
-- Joins with tables not supported
|
||||||
UPDATE users_test_table
|
UPDATE users_test_table
|
||||||
SET value_2 = 5
|
SET value_2 = 5
|
||||||
FROM events_test_table_local
|
FROM events_test_table_local
|
||||||
WHERE users_test_table.user_id = events_test_table_local.user_id;
|
WHERE users_test_table.user_id = events_test_table_local.user_id;
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
|
||||||
UPDATE events_test_table_local
|
UPDATE events_test_table_local
|
||||||
SET value_2 = 5
|
SET value_2 = 5
|
||||||
FROM users_test_table
|
FROM users_test_table
|
||||||
WHERE events_test_table_local.user_id = users_test_table.user_id;
|
WHERE events_test_table_local.user_id = users_test_table.user_id;
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
|
||||||
-- Local tables in a subquery are supported through recursive planning
|
-- Local tables in a subquery are supported through recursive planning
|
||||||
UPDATE users_test_table
|
UPDATE users_test_table
|
||||||
SET value_2 = 5
|
SET value_2 = 5
|
||||||
|
|
|
@ -280,15 +280,20 @@ ORDER BY articles.id;
|
||||||
-- subqueries are not supported in SELECT clause
|
-- subqueries are not supported in SELECT clause
|
||||||
SELECT a.title AS name, (SELECT a2.id FROM articles_single_shard a2 WHERE a.id = a2.id LIMIT 1)
|
SELECT a.title AS name, (SELECT a2.id FROM articles_single_shard a2 WHERE a.id = a2.id LIMIT 1)
|
||||||
AS special_price FROM articles a;
|
AS special_price FROM articles a;
|
||||||
ERROR: complex joins are only supported when all distributed tables are co-located and joined on their distribution columns
|
ERROR: could not run distributed query with subquery outside the FROM, WHERE and HAVING clauses
|
||||||
-- joins are not supported between local and distributed tables
|
HINT: Consider using an equality filter on the distributed table's partition column.
|
||||||
|
-- joins are supported between local and distributed tables
|
||||||
SELECT title, authors.name FROM authors, articles WHERE authors.id = articles.author_id;
|
SELECT title, authors.name FROM authors, articles WHERE authors.id = articles.author_id;
|
||||||
ERROR: direct joins between distributed and local tables are not supported
|
title | name
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
---------------------------------------------------------------------
|
||||||
-- inner joins are not supported (I think)
|
(0 rows)
|
||||||
|
|
||||||
|
-- inner joins are supported
|
||||||
SELECT * FROM (articles INNER JOIN authors ON articles.id = authors.id);
|
SELECT * FROM (articles INNER JOIN authors ON articles.id = authors.id);
|
||||||
ERROR: direct joins between distributed and local tables are not supported
|
id | author_id | title | word_count | name | id
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
-- test use of EXECUTE statements within plpgsql
|
-- test use of EXECUTE statements within plpgsql
|
||||||
DO $sharded_execute$
|
DO $sharded_execute$
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -226,12 +226,12 @@ SELECT a.title AS name, (SELECT a2.id FROM articles_single_shard a2 WHERE a.id =
|
||||||
AS special_price FROM articles a;
|
AS special_price FROM articles a;
|
||||||
ERROR: could not run distributed query with subquery outside the FROM, WHERE and HAVING clauses
|
ERROR: could not run distributed query with subquery outside the FROM, WHERE and HAVING clauses
|
||||||
HINT: Consider using an equality filter on the distributed table's partition column.
|
HINT: Consider using an equality filter on the distributed table's partition column.
|
||||||
-- joins are not supported between local and distributed tables
|
-- joins are supported between local and distributed tables
|
||||||
SELECT title, authors.name FROM authors, articles WHERE authors.id = articles.author_id;
|
SELECT title, authors.name FROM authors, articles WHERE authors.id = articles.author_id;
|
||||||
ERROR: relation authors is not distributed
|
ERROR: Complex subqueries and CTEs are not supported when task_executor_type is set to 'task-tracker'
|
||||||
-- inner joins are not supported (I think)
|
-- inner joins are supported
|
||||||
SELECT * FROM (articles INNER JOIN authors ON articles.id = authors.id);
|
SELECT * FROM (articles INNER JOIN authors ON articles.id = authors.id);
|
||||||
ERROR: relation authors is not distributed
|
ERROR: Complex subqueries and CTEs are not supported when task_executor_type is set to 'task-tracker'
|
||||||
-- test use of EXECUTE statements within plpgsql
|
-- test use of EXECUTE statements within plpgsql
|
||||||
DO $sharded_execute$
|
DO $sharded_execute$
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -302,13 +302,16 @@ SELECT min(user_id) FROM cte JOIN local_table ON (user_id = id);
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- not if there are no distributed tables
|
-- even if there are no distributed tables
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT user_id FROM users_table
|
SELECT user_id FROM users_table
|
||||||
)
|
)
|
||||||
SELECT min(user_id) FROM cte JOIN local_table ON (user_id = id) JOIN events_table USING (user_id);
|
SELECT min(user_id) FROM cte JOIN local_table ON (user_id = id) JOIN events_table USING (user_id);
|
||||||
ERROR: direct joins between distributed and local tables are not supported
|
min
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
---------------------------------------------------------------------
|
||||||
|
1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- unless the distributed table is part of a recursively planned subquery
|
-- unless the distributed table is part of a recursively planned subquery
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT user_id FROM users_table
|
SELECT user_id FROM users_table
|
||||||
|
@ -319,15 +322,18 @@ SELECT min(user_id) FROM cte JOIN local_table ON (user_id = id) JOIN (SELECT * F
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- joins between local and reference tables not allowed
|
-- joins between local and reference tables are allowed
|
||||||
-- since the coordinator is not in the metadata at this stage
|
-- even when the coordinator is not in the metadata at this stage
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT user_id FROM users_table
|
SELECT user_id FROM users_table
|
||||||
)
|
)
|
||||||
SELECT count(*) FROM local_table JOIN ref_table USING (id)
|
SELECT count(*) FROM local_table JOIN ref_table USING (id)
|
||||||
WHERE id IN (SELECT * FROM cte);
|
WHERE id IN (SELECT * FROM cte);
|
||||||
ERROR: direct joins between distributed and local tables are not supported
|
count
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
---------------------------------------------------------------------
|
||||||
|
6
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- CTEs should be able to terminate a router query
|
-- CTEs should be able to terminate a router query
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
WITH cte_1 AS (
|
WITH cte_1 AS (
|
||||||
|
|
|
@ -668,19 +668,20 @@ SELECT * FROM raw_data ORDER BY val;
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- Test that local tables are barred
|
-- Test that local tables are can be updated
|
||||||
|
-- selecting from distributed tables
|
||||||
UPDATE local_table lt SET val = mt.val
|
UPDATE local_table lt SET val = mt.val
|
||||||
FROM modify_table mt WHERE mt.id = lt.id;
|
FROM modify_table mt WHERE mt.id = lt.id;
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
|
||||||
-- Including inside CTEs
|
-- Including inside CTEs
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
UPDATE local_table lt SET val = mt.val
|
UPDATE local_table lt SET val = mt.val
|
||||||
FROM modify_table mt WHERE mt.id = lt.id
|
FROM modify_table mt WHERE mt.id = lt.id
|
||||||
RETURNING lt.id, lt.val
|
RETURNING lt.id, lt.val
|
||||||
) SELECT * FROM cte JOIN modify_table mt ON mt.id = cte.id ORDER BY 1,2;
|
) SELECT * FROM cte JOIN modify_table mt ON mt.id = cte.id ORDER BY 1,2;
|
||||||
ERROR: cannot plan modifications with local tables involving citus tables
|
id | val | id | val
|
||||||
HINT: Use CTE's or subqueries to select from local tables and use them in joins
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
-- Make sure checks for volatile functions apply to CTEs too
|
-- Make sure checks for volatile functions apply to CTEs too
|
||||||
WITH cte AS (UPDATE modify_table SET val = random() WHERE id = 3 RETURNING *)
|
WITH cte AS (UPDATE modify_table SET val = random() WHERE id = 3 RETURNING *)
|
||||||
SELECT * FROM cte JOIN modify_table mt ON mt.id = 3 AND mt.id = cte.id ORDER BY 1,2;
|
SELECT * FROM cte JOIN modify_table mt ON mt.id = 3 AND mt.id = cte.id ORDER BY 1,2;
|
||||||
|
|
|
@ -169,8 +169,8 @@ CREATE TABLE dist_table(a int);
|
||||||
SELECT create_distributed_table('dist_table', 'a');
|
SELECT create_distributed_table('dist_table', 'a');
|
||||||
INSERT INTO dist_table VALUES(1);
|
INSERT INTO dist_table VALUES(1);
|
||||||
|
|
||||||
SELECT * FROM local JOIN dist_table ON (a = x);
|
SELECT * FROM local JOIN dist_table ON (a = x) ORDER BY 1,2,3;
|
||||||
SELECT * FROM local JOIN dist_table ON (a = x) WHERE a = 1;;
|
SELECT * FROM local JOIN dist_table ON (a = x) WHERE a = 1 ORDER BY 1,2,3;
|
||||||
|
|
||||||
-- intermediate results are allowed
|
-- intermediate results are allowed
|
||||||
WITH cte_1 AS (SELECT * FROM dist_table ORDER BY 1 LIMIT 1)
|
WITH cte_1 AS (SELECT * FROM dist_table ORDER BY 1 LIMIT 1)
|
||||||
|
|
|
@ -281,8 +281,10 @@ SET dept = 5
|
||||||
FROM cte_1
|
FROM cte_1
|
||||||
WHERE distributed_table.tenant_id < cte_1.tenant_id;
|
WHERE distributed_table.tenant_id < cte_1.tenant_id;
|
||||||
|
|
||||||
-- we don't support updating local table with a join with
|
-- we support updating local table with a join with
|
||||||
-- distributed tables
|
-- distributed tables, though as the local table
|
||||||
|
-- is target here, distributed table is recursively
|
||||||
|
-- planned
|
||||||
UPDATE
|
UPDATE
|
||||||
local_table
|
local_table
|
||||||
SET
|
SET
|
||||||
|
|
|
@ -327,7 +327,7 @@ UPDATE limit_orders SET id = 246 WHERE id = 246;
|
||||||
UPDATE limit_orders SET id = 246 WHERE id = 246 AND symbol = 'GM';
|
UPDATE limit_orders SET id = 246 WHERE id = 246 AND symbol = 'GM';
|
||||||
UPDATE limit_orders SET id = limit_orders.id WHERE id = 246;
|
UPDATE limit_orders SET id = limit_orders.id WHERE id = 246;
|
||||||
|
|
||||||
-- UPDATEs with a FROM clause are unsupported
|
-- UPDATEs with a FROM clause are supported even with local tables
|
||||||
UPDATE limit_orders SET limit_price = 0.00 FROM bidders
|
UPDATE limit_orders SET limit_price = 0.00 FROM bidders
|
||||||
WHERE limit_orders.id = 246 AND
|
WHERE limit_orders.id = 246 AND
|
||||||
limit_orders.bidder_id = bidders.id AND
|
limit_orders.bidder_id = bidders.id AND
|
||||||
|
|
|
@ -609,7 +609,7 @@ WHERE users_test_table.user_id = subquery.user_id;
|
||||||
-- Make following tests consistent
|
-- Make following tests consistent
|
||||||
UPDATE users_test_table SET value_2 = 0;
|
UPDATE users_test_table SET value_2 = 0;
|
||||||
|
|
||||||
-- Local tables are not supported
|
-- Joins with tables not supported
|
||||||
UPDATE users_test_table
|
UPDATE users_test_table
|
||||||
SET value_2 = 5
|
SET value_2 = 5
|
||||||
FROM events_test_table_local
|
FROM events_test_table_local
|
||||||
|
|
|
@ -146,10 +146,10 @@ ORDER BY articles.id;
|
||||||
SELECT a.title AS name, (SELECT a2.id FROM articles_single_shard a2 WHERE a.id = a2.id LIMIT 1)
|
SELECT a.title AS name, (SELECT a2.id FROM articles_single_shard a2 WHERE a.id = a2.id LIMIT 1)
|
||||||
AS special_price FROM articles a;
|
AS special_price FROM articles a;
|
||||||
|
|
||||||
-- joins are not supported between local and distributed tables
|
-- joins are supported between local and distributed tables
|
||||||
SELECT title, authors.name FROM authors, articles WHERE authors.id = articles.author_id;
|
SELECT title, authors.name FROM authors, articles WHERE authors.id = articles.author_id;
|
||||||
|
|
||||||
-- inner joins are not supported (I think)
|
-- inner joins are supported
|
||||||
SELECT * FROM (articles INNER JOIN authors ON articles.id = authors.id);
|
SELECT * FROM (articles INNER JOIN authors ON articles.id = authors.id);
|
||||||
|
|
||||||
-- test use of EXECUTE statements within plpgsql
|
-- test use of EXECUTE statements within plpgsql
|
||||||
|
|
|
@ -231,7 +231,7 @@ WITH cte AS (
|
||||||
)
|
)
|
||||||
SELECT min(user_id) FROM cte JOIN local_table ON (user_id = id);
|
SELECT min(user_id) FROM cte JOIN local_table ON (user_id = id);
|
||||||
|
|
||||||
-- not if there are no distributed tables
|
-- even if there are no distributed tables
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT user_id FROM users_table
|
SELECT user_id FROM users_table
|
||||||
)
|
)
|
||||||
|
@ -243,8 +243,8 @@ WITH cte AS (
|
||||||
)
|
)
|
||||||
SELECT min(user_id) FROM cte JOIN local_table ON (user_id = id) JOIN (SELECT * FROM events_table OFFSET 0) e USING (user_id);
|
SELECT min(user_id) FROM cte JOIN local_table ON (user_id = id) JOIN (SELECT * FROM events_table OFFSET 0) e USING (user_id);
|
||||||
|
|
||||||
-- joins between local and reference tables not allowed
|
-- joins between local and reference tables are allowed
|
||||||
-- since the coordinator is not in the metadata at this stage
|
-- even when the coordinator is not in the metadata at this stage
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT user_id FROM users_table
|
SELECT user_id FROM users_table
|
||||||
)
|
)
|
||||||
|
|
|
@ -412,7 +412,8 @@ raw_data AS (
|
||||||
)
|
)
|
||||||
SELECT * FROM raw_data ORDER BY val;
|
SELECT * FROM raw_data ORDER BY val;
|
||||||
|
|
||||||
-- Test that local tables are barred
|
-- Test that local tables are can be updated
|
||||||
|
-- selecting from distributed tables
|
||||||
UPDATE local_table lt SET val = mt.val
|
UPDATE local_table lt SET val = mt.val
|
||||||
FROM modify_table mt WHERE mt.id = lt.id;
|
FROM modify_table mt WHERE mt.id = lt.id;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue