Continue fixing multi tests

onder_view
Burak Velioglu 2022-04-13 00:05:11 +03:00
parent 68b291754b
commit 69cf83ca22
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
14 changed files with 113 additions and 5 deletions

View File

@ -575,6 +575,9 @@ CREATE TABLE local(a int, b bigserial, c int default nextval('c_seq'));
INSERT INTO local VALUES (3);
create materialized view m_local as select * from local;
create view v_local as select * from local;
WARNING: "view v_local" has dependency to "table local" that is not in Citus' metadata
DETAIL: "view v_local" will be created only locally
HINT: Distribute "table local" first to distribute "view v_local"
CREATE TABLE ref(a int);
SELECT create_Reference_table('ref');
create_reference_table
@ -604,6 +607,13 @@ DETAIL: drop cascades to materialized view m_local
drop cascades to view v_local
CONTEXT: SQL statement "DROP TABLE alter_table_set_access_method.local CASCADE"
NOTICE: renaming the new table to alter_table_set_access_method.local
WARNING: "view v_local" has dependency to "table local" that is not in Citus' metadata
DETAIL: "view v_local" will be created only locally
HINT: Distribute "table local" first to distribute "view v_local"
CONTEXT: SQL statement "CREATE VIEW alter_table_set_access_method.v_local AS SELECT local.a,
local.b,
local.c
FROM local;"
alter_table_set_access_method
---------------------------------------------------------------------
@ -623,6 +633,8 @@ NOTICE: renaming the new table to alter_table_set_access_method.ref
(1 row)
-- (TODO: CHECK) Since there is a dependent view, we must use sequential mode
SET citus.multi_shard_modify_mode TO 'sequential';
select alter_table_set_access_method('dist','columnar');
NOTICE: creating a new table for alter_table_set_access_method.dist
NOTICE: moving the data of alter_table_set_access_method.dist
@ -651,6 +663,7 @@ NOTICE: renaming the new table to alter_table_set_access_method.dist
(1 row)
RESET citus.multi_shard_modify_mode;
select alter_table_set_access_method('local','heap');
NOTICE: creating a new table for alter_table_set_access_method.local
NOTICE: moving the data of alter_table_set_access_method.local
@ -660,6 +673,13 @@ DETAIL: drop cascades to materialized view m_local
drop cascades to view v_local
CONTEXT: SQL statement "DROP TABLE alter_table_set_access_method.local CASCADE"
NOTICE: renaming the new table to alter_table_set_access_method.local
WARNING: "view v_local" has dependency to "table local" that is not in Citus' metadata
DETAIL: "view v_local" will be created only locally
HINT: Distribute "table local" first to distribute "view v_local"
CONTEXT: SQL statement "CREATE VIEW alter_table_set_access_method.v_local AS SELECT local.a,
local.b,
local.c
FROM local;"
alter_table_set_access_method
---------------------------------------------------------------------
@ -679,6 +699,8 @@ NOTICE: renaming the new table to alter_table_set_access_method.ref
(1 row)
-- (TODO: CHECK) Since there is a dependent view, we must use sequential mode
SET citus.multi_shard_modify_mode TO 'sequential';
select alter_table_set_access_method('dist','heap');
NOTICE: creating a new table for alter_table_set_access_method.dist
NOTICE: moving the data of alter_table_set_access_method.dist
@ -693,6 +715,7 @@ NOTICE: renaming the new table to alter_table_set_access_method.dist
(1 row)
RESET citus.multi_shard_modify_mode;
SELECT * FROM m_local;
a | b | c
---------------------------------------------------------------------

View File

@ -4302,6 +4302,8 @@ WHERE schemaname = 'partitioning_schema' AND tablename ilike '%part_table_with_%
-- should work properly - no names clashes
SELECT 1 FROM citus_activate_node('localhost', :worker_1_port);
NOTICE: Replicating postgres objects to node localhost:xxxxx
DETAIL: There are 106 objects to replicate, depending on your environment this might take a while
?column?
---------------------------------------------------------------------
1

View File

@ -1076,7 +1076,6 @@ ERROR: cannot pushdown the subquery
-- make sure that non-colocated subquery joins work fine in
-- modifications
CREATE TABLE table1 (id int, tenant_id int);
CREATE VIEW table1_view AS SELECT * from table1 where id < 100;
CREATE TABLE table2 (id int, tenant_id int) partition by range(tenant_id);
CREATE TABLE table2_p1 PARTITION OF table2 FOR VALUES FROM (1) TO (10);
-- modifications on the partitons are only allowed with rep=1
@ -1093,6 +1092,8 @@ SELECT create_distributed_table('table1','tenant_id');
(1 row)
CREATE VIEW table1_view AS SELECT * from table1 where id < 100;
DEBUG: switching to sequential query execution mode
-- all of the above queries are non-colocated subquery joins
-- because the views are replaced with subqueries
UPDATE table2 SET id=20 FROM table1_view WHERE table1_view.id=table2.id;

View File

@ -50,8 +50,9 @@ ON TRUE
---------------------------------------------------------------------
("composite type","""object prop""",t1,"""object prop"".t1")
(schema,,"""object prop""","""object prop""")
(table,"""object prop""",test,"""object prop"".test")
(type,"""object prop""",t1,"""object prop"".t1")
(3 rows)
(4 rows)
-- find all the dependencies of type t1
SELECT

View File

@ -12,6 +12,9 @@ CREATE RECURSIVE VIEW recursive_view(val_1, val_2) AS
WHERE val_2 < 50
);
CREATE RECURSIVE VIEW recursive_defined_non_recursive_view(c) AS (SELECT 1 FROM local_table);
WARNING: "view recursive_defined_non_recursive_view" has dependency to "table local_table" that is not in Citus' metadata
DETAIL: "view recursive_defined_non_recursive_view" will be created only locally
HINT: Distribute "table local_table" first to distribute "view recursive_defined_non_recursive_view"
CREATE TABLE ref_table(a int, b INT);
SELECT create_reference_table('ref_table');
create_reference_table

View File

@ -978,6 +978,8 @@ DEBUG: Creating router plan
SET citus.enable_repartition_joins TO OFF;
-- this should be recursively planned
CREATE VIEW set_view_recursive AS (SELECT y FROM test) UNION (SELECT y FROM test);
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT * FROM set_view_recursive ORDER BY 1 DESC;
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Router planner cannot handle multi-shard select queries
@ -996,6 +998,8 @@ DEBUG: Creating router plan
-- this should be pushed down
CREATE VIEW set_view_pushdown AS (SELECT x FROM test) UNION (SELECT x FROM test);
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT * FROM set_view_pushdown ORDER BY 1 DESC;
DEBUG: Router planner cannot handle multi-shard select queries
x
@ -1006,6 +1010,8 @@ DEBUG: Router planner cannot handle multi-shard select queries
-- this should be recursively planned
CREATE VIEW set_view_recursive_second AS SELECT u.x, test.y FROM ((SELECT x, y FROM test) UNION (SELECT 1, 1 FROM test)) u JOIN test USING (x) ORDER BY 1,2;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT * FROM set_view_recursive_second ORDER BY 1,2;
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Router planner cannot handle multi-shard select queries

View File

@ -278,6 +278,8 @@ ORDER BY 1 LIMIT 3;
ERROR: correlated subqueries are not supported when the FROM clause contains a subquery without FROM
-- sublink on view
CREATE TEMP VIEW view_1 AS (SELECT user_id, value_2 FROM users_table WHERE user_id = 1 AND value_1 = 1 ORDER BY 1,2);
WARNING: "view view_1" has dependency on unsupported object "schema pg_temp_xxx"
DETAIL: "view view_1" will be created only locally
-- with distribution column group by
SELECT (SELECT value_2 FROM view_1 WHERE user_id = e.user_id GROUP BY user_id, value_2)
FROM events_table e
@ -323,6 +325,8 @@ ORDER BY 1 LIMIT 3;
-- sublink on reference table view
CREATE TEMP VIEW view_2 AS (SELECT user_id, value_2 FROM users_reference_table WHERE user_id = 1 AND value_1 = 1);
WARNING: "view view_2" has dependency on unsupported object "schema pg_temp_xxx"
DETAIL: "view view_2" will be created only locally
SELECT (SELECT value_2 FROM view_2 WHERE user_id = e.user_id GROUP BY user_id, value_2)
FROM events_table e
GROUP BY 1

View File

@ -1096,6 +1096,8 @@ CREATE TEMPORARY VIEW correlated_subquery_view AS
FROM events_table e1
WHERE e1.user_id = u1.user_id
) > 0;
WARNING: "view correlated_subquery_view" has dependency on unsupported object "schema pg_temp_xxx"
DETAIL: "view correlated_subquery_view" will be created only locally
SELECT sum(user_id) FROM correlated_subquery_view;
sum
---------------------------------------------------------------------

View File

@ -209,6 +209,9 @@ FROM
) as foo
WHERE foo.user_id = cte.user_id
) as foo, users_table WHERE foo.cnt > users_table.value_2;
WARNING: "view subquery_and_ctes" has dependency to "table users_table_local" that is not in Citus' metadata
DETAIL: "view subquery_and_ctes" will be created only locally
HINT: Distribute "table users_table_local" first to distribute "view subquery_and_ctes"
SELECT * FROM subquery_and_ctes
ORDER BY 3 DESC, 1 DESC, 2 DESC, 4 DESC
LIMIT 5;

View File

@ -16,6 +16,8 @@ SELECT
users_table.user_id = events_table.user_id AND
event_type IN (1,2,3,4)
ORDER BY 1 DESC;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT
*
FROM
@ -42,6 +44,8 @@ SELECT
event_type IN (1,2,3,4)
ORDER BY 1 DESC
LIMIT 5;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT
*
FROM
@ -74,6 +78,8 @@ FROM
ORDER BY 1 DESC LIMIT 5
) as foo
ORDER BY 1 DESC;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT * FROM subquery_limit ORDER BY 1 DESC;
DEBUG: push down of limit count: 5
DEBUG: generating subplan XXX_1 for subquery SELECT DISTINCT users_table.user_id FROM public.users_table, public.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2, 3, 4]))) ORDER BY users_table.user_id DESC LIMIT 5
@ -102,6 +108,8 @@ FROM
ORDER BY 1
) as foo
ORDER BY 1 DESC;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT * FROM subquery_non_p_key_group_by ORDER BY 1 DESC;
DEBUG: generating subplan XXX_1 for subquery SELECT DISTINCT users_table.value_1 FROM public.users_table, public.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2, 3, 4]))) ORDER BY users_table.value_1
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT value_1 FROM (SELECT foo.value_1 FROM (SELECT intermediate_result.value_1 FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer)) foo ORDER BY foo.value_1 DESC) subquery_non_p_key_group_by ORDER BY value_1 DESC
@ -141,6 +149,8 @@ FROM
) as bar
WHERE foo.value_2 = bar.value_3
ORDER BY 2 DESC, 1;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT * FROM final_query_router ORDER BY 1;
DEBUG: generating subplan XXX_1 for subquery SELECT users_table.value_2 FROM public.users_table, public.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2, 3, 4]))) GROUP BY users_table.value_2 ORDER BY users_table.value_2 DESC
DEBUG: generating subplan XXX_2 for subquery SELECT users_table.value_3 FROM public.users_table, public.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[5, 6, 7, 8]))) GROUP BY users_table.value_3 ORDER BY users_table.value_3 DESC
@ -181,6 +191,8 @@ FROM
WHERE foo.value_2 = bar.user_id
ORDER BY 2 DESC, 1 DESC
LIMIT 3;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT
DISTINCT ON (users_table.value_2) users_table.value_2, time, value_3
FROM
@ -206,6 +218,8 @@ SELECT DISTINCT user_id
FROM users_table
WHERE
user_id IN (SELECT DISTINCT value_2 FROM users_table WHERE value_1 >= 1 AND value_1 <= 20 ORDER BY 1 LIMIT 5);
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT
*
FROM
@ -248,6 +262,8 @@ FROM (
) t
GROUP BY user_id
) q;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT
*
FROM
@ -281,6 +297,9 @@ FROM
) as baz
WHERE baz.user_id = users_table.user_id
) as sub1;
WARNING: "view subquery_from_from_where_local_table" has dependency to "table events_table_local" that is not in Citus' metadata
DETAIL: "view subquery_from_from_where_local_table" will be created only locally
HINT: Distribute "table events_table_local" first to distribute "view subquery_from_from_where_local_table"
SELECT
*
FROM
@ -308,6 +327,8 @@ FROM
SELECT user_id FROM users_table
) as bar
WHERE foo.value_2 = bar.user_id;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT
*
FROM
@ -337,6 +358,9 @@ FROM
SELECT user_id FROM users_table_local WHERE user_id = 2
) baw
WHERE foo.value_2 = bar.user_id AND baz.value_2 = bar.user_id AND bar.user_id = baw.user_id;
WARNING: "view all_executors_view" has dependency to "table users_table_local" that is not in Citus' metadata
DETAIL: "view all_executors_view" will be created only locally
HINT: Distribute "table users_table_local" first to distribute "view all_executors_view"
SELECT
*
FROM
@ -390,6 +414,9 @@ FROM
) as foo
WHERE foo.user_id = cte.user_id
) as foo, users_table WHERE foo.cnt > users_table.value_2;
WARNING: "view subquery_and_ctes" has dependency to "table users_table_local" that is not in Citus' metadata
DETAIL: "view subquery_and_ctes" will be created only locally
HINT: Distribute "table users_table_local" first to distribute "view subquery_and_ctes"
SELECT * FROM subquery_and_ctes
ORDER BY 3 DESC, 1 DESC, 2 DESC, 4 DESC
LIMIT 5;
@ -437,6 +464,9 @@ SELECT time, event_type, value_2, value_3 FROM
events_table
WHERE
foo.user_id = events_table.value_2;
WARNING: "view subquery_and_ctes_second" has dependency to "table users_table_local" that is not in Citus' metadata
DETAIL: "view subquery_and_ctes_second" will be created only locally
HINT: Distribute "table users_table_local" first to distribute "view subquery_and_ctes_second"
SELECT * FROM subquery_and_ctes_second
ORDER BY 3 DESC, 2 DESC, 1 DESC
LIMIT 5;
@ -499,6 +529,8 @@ FROM
) as level_6, users_table WHERE users_table.user_id = level_6.min
GROUP BY users_table.value_1
) as bar;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT
*
FROM
@ -530,6 +562,8 @@ FROM
ORDER BY 1 DESC LIMIT 5
) as foo
ORDER BY 1 DESC;
DEBUG: switching to sequential query execution mode
DETAIL: A command for a distributed view is run. To make sure subsequent commands see the view correctly we need to make sure to use only one connection for all future commands
SELECT
*
FROM

View File

@ -340,6 +340,25 @@ drop cascades to view undis_view2
drop cascades to view another_schema.undis_view3
CONTEXT: SQL statement "DROP TABLE undistribute_table.view_table CASCADE"
NOTICE: renaming the new table to undistribute_table.view_table
WARNING: "view undis_view1" has dependency to "table view_table" that is not in Citus' metadata
DETAIL: "view undis_view1" will be created only locally
HINT: Distribute "table view_table" first to distribute "view undis_view1"
CONTEXT: SQL statement "CREATE VIEW undistribute_table.undis_view1 AS SELECT view_table.a,
view_table.b
FROM view_table;"
WARNING: "view undis_view2" has dependency to "table view_table" that is not in Citus' metadata
DETAIL: "view undis_view2" will be created only locally
HINT: Distribute "table view_table" first to distribute "view undis_view2"
CONTEXT: SQL statement "CREATE VIEW undistribute_table.undis_view2 AS SELECT view_table.a,
view_table.c
FROM view_table;"
WARNING: "view another_schema.undis_view3" has dependency to "table view_table" that is not in Citus' metadata
DETAIL: "view another_schema.undis_view3" will be created only locally
HINT: Distribute "table view_table" first to distribute "view another_schema.undis_view3"
CONTEXT: SQL statement "CREATE VIEW another_schema.undis_view3 AS SELECT undis_view1.b,
undis_view2.c
FROM (undis_view1
JOIN undis_view2 ON ((undis_view1.a = undis_view2.a)));"
undistribute_table
---------------------------------------------------------------------

View File

@ -899,6 +899,9 @@ INSERT INTO range_dist_table_2 VALUES ((10, 91));
INSERT INTO range_dist_table_2 VALUES ((20, 100));
-- the following can be pushed down
CREATE OR REPLACE VIEW v2 AS SELECT * from range_dist_table_2 UNION ALL SELECT * from range_dist_table_2;
WARNING: "view v2" has dependency to "table range_dist_table_2" that is not in Citus' metadata
DETAIL: "view v2" will be created only locally
HINT: Distribute "table range_dist_table_2" first to distribute "view v2"
SELECT public.explain_has_distributed_subplan($$
EXPLAIN
SELECT COUNT(dist_col) FROM v2;

View File

@ -222,14 +222,20 @@ create view v_dist as select * from dist;
select alter_table_set_access_method('local','columnar');
select alter_table_set_access_method('ref','columnar');
-- (TODO: CHECK) Since there is a dependent view, we must use sequential mode
SET citus.multi_shard_modify_mode TO 'sequential';
select alter_table_set_access_method('dist','columnar');
SELECT alter_distributed_table('dist', shard_count:=1, cascade_to_colocated:=false);
RESET citus.multi_shard_modify_mode;
select alter_table_set_access_method('local','heap');
select alter_table_set_access_method('ref','heap');
-- (TODO: CHECK) Since there is a dependent view, we must use sequential mode
SET citus.multi_shard_modify_mode TO 'sequential';
select alter_table_set_access_method('dist','heap');
RESET citus.multi_shard_modify_mode;
SELECT * FROM m_local;
SELECT * FROM m_ref;

View File

@ -785,7 +785,6 @@ SELECT count(*) FROM events_table WHERE user_id NOT IN
-- make sure that non-colocated subquery joins work fine in
-- modifications
CREATE TABLE table1 (id int, tenant_id int);
CREATE VIEW table1_view AS SELECT * from table1 where id < 100;
CREATE TABLE table2 (id int, tenant_id int) partition by range(tenant_id);
CREATE TABLE table2_p1 PARTITION OF table2 FOR VALUES FROM (1) TO (10);
@ -795,6 +794,8 @@ SET citus.shard_replication_factor TO 1;
SELECT create_distributed_table('table2','tenant_id');
SELECT create_distributed_table('table1','tenant_id');
CREATE VIEW table1_view AS SELECT * from table1 where id < 100;
-- all of the above queries are non-colocated subquery joins
-- because the views are replaced with subqueries
UPDATE table2 SET id=20 FROM table1_view WHERE table1_view.id=table2.id;