mirror of https://github.com/citusdata/citus.git
376 lines
16 KiB
Plaintext
376 lines
16 KiB
Plaintext
--
|
|
-- MULTI_MX_SCHEMA_SUPPORT
|
|
--
|
|
-- connect to a worker node and run some queries
|
|
\c - - - :worker_1_port
|
|
-- test very basic queries
|
|
SELECT * FROM nation_hash ORDER BY n_nationkey LIMIT 4;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+-------------------------------------------------------------------------------------------------------------
|
|
0 | ALGERIA | 0 | haggle. carefully final deposits detect slyly agai
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
2 | BRAZIL | 1 | y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special
|
|
3 | CANADA | 1 | eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold
|
|
(4 rows)
|
|
|
|
SELECT * FROM citus_mx_test_schema.nation_hash ORDER BY n_nationkey LIMIT 4;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+-------------------------------------------------------------------------------------------------------------
|
|
0 | ALGERIA | 0 | haggle. carefully final deposits detect slyly agai
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
2 | BRAZIL | 1 | y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special
|
|
3 | CANADA | 1 | eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold
|
|
(4 rows)
|
|
|
|
-- test cursors
|
|
SET search_path TO public;
|
|
BEGIN;
|
|
DECLARE test_cursor CURSOR FOR
|
|
SELECT *
|
|
FROM nation_hash
|
|
WHERE n_nationkey = 1;
|
|
FETCH test_cursor;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+------------------------------------------------------------------------------
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
(1 row)
|
|
|
|
FETCH test_cursor;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+--------+-------------+-----------
|
|
(0 rows)
|
|
|
|
FETCH BACKWARD test_cursor;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+------------------------------------------------------------------------------
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
(1 row)
|
|
|
|
END;
|
|
-- test with search_path is set
|
|
SET search_path TO citus_mx_test_schema;
|
|
BEGIN;
|
|
DECLARE test_cursor CURSOR FOR
|
|
SELECT *
|
|
FROM nation_hash
|
|
WHERE n_nationkey = 1;
|
|
FETCH test_cursor;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+------------------------------------------------------------------------------
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
(1 row)
|
|
|
|
FETCH test_cursor;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+--------+-------------+-----------
|
|
(0 rows)
|
|
|
|
FETCH BACKWARD test_cursor;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+------------------------------------------------------------------------------
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
(1 row)
|
|
|
|
END;
|
|
-- test inserting to table in different schema
|
|
SET search_path TO public;
|
|
INSERT INTO citus_mx_test_schema.nation_hash(n_nationkey, n_name, n_regionkey) VALUES (100, 'TURKEY', 3);
|
|
-- verify insertion
|
|
SELECT * FROM citus_mx_test_schema.nation_hash WHERE n_nationkey = 100;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+-----------
|
|
100 | TURKEY | 3 |
|
|
(1 row)
|
|
|
|
-- test with search_path is set
|
|
SET search_path TO citus_mx_test_schema;
|
|
INSERT INTO nation_hash(n_nationkey, n_name, n_regionkey) VALUES (101, 'GERMANY', 3);
|
|
-- verify insertion
|
|
SELECT * FROM nation_hash WHERE n_nationkey = 101;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+-----------
|
|
101 | GERMANY | 3 |
|
|
(1 row)
|
|
|
|
-- TODO: add UPDATE/DELETE/UPSERT
|
|
-- test UDFs with schemas
|
|
SET search_path TO public;
|
|
-- UDF in public, table in a schema other than public, search_path is not set
|
|
SELECT simpleTestFunction(n_nationkey)::int FROM citus_mx_test_schema.nation_hash GROUP BY 1 ORDER BY 1 DESC LIMIT 5;
|
|
simpletestfunction
|
|
--------------------
|
|
152
|
|
151
|
|
37
|
|
35
|
|
34
|
|
(5 rows)
|
|
|
|
-- UDF in public, table in a schema other than public, search_path is set
|
|
SET search_path TO citus_mx_test_schema;
|
|
SELECT public.simpleTestFunction(n_nationkey)::int FROM citus_mx_test_schema.nation_hash GROUP BY 1 ORDER BY 1 DESC LIMIT 5;
|
|
simpletestfunction
|
|
--------------------
|
|
152
|
|
151
|
|
37
|
|
35
|
|
34
|
|
(5 rows)
|
|
|
|
-- UDF in schema, table in a schema other than public, search_path is not set
|
|
SET search_path TO public;
|
|
SELECT citus_mx_test_schema.simpleTestFunction2(n_nationkey)::int FROM citus_mx_test_schema.nation_hash GROUP BY 1 ORDER BY 1 DESC LIMIT 5;
|
|
simpletestfunction2
|
|
---------------------
|
|
152
|
|
151
|
|
37
|
|
35
|
|
34
|
|
(5 rows)
|
|
|
|
-- UDF in schema, table in a schema other than public, search_path is set
|
|
SET search_path TO citus_mx_test_schema;
|
|
SELECT simpleTestFunction2(n_nationkey)::int FROM nation_hash GROUP BY 1 ORDER BY 1 DESC LIMIT 5;
|
|
simpletestfunction2
|
|
---------------------
|
|
152
|
|
151
|
|
37
|
|
35
|
|
34
|
|
(5 rows)
|
|
|
|
-- test operators with schema
|
|
SET search_path TO public;
|
|
-- test with search_path is not set
|
|
SELECT * FROM citus_mx_test_schema.nation_hash WHERE n_nationkey OPERATOR(citus_mx_test_schema.===) 1;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+------------------------------------------------------------------------------
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
(1 row)
|
|
|
|
-- test with search_path is set
|
|
SET search_path TO citus_mx_test_schema;
|
|
SELECT * FROM nation_hash WHERE n_nationkey OPERATOR(===) 1;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+------------------------------------------------------------------------------
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
(1 row)
|
|
|
|
SELECT * FROM citus_mx_test_schema.nation_hash_collation_search_path;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+-------------------------------------------------------------------------------------------------------------
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
5 | ETHIOPIA | 0 | ven packages wake quickly. regu
|
|
0 | ALGERIA | 0 | haggle. carefully final deposits detect slyly agai
|
|
3 | CANADA | 1 | eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold
|
|
4 | EGYPT | 4 | y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d
|
|
2 | BRAZIL | 1 | y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special
|
|
(6 rows)
|
|
|
|
SELECT n_comment FROM citus_mx_test_schema.nation_hash_collation_search_path ORDER BY n_comment COLLATE citus_mx_test_schema.english;
|
|
n_comment
|
|
-------------------------------------------------------------------------------------------------------------
|
|
al foxes promise slyly according to the regular accounts. bold requests alon
|
|
eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold
|
|
haggle. carefully final deposits detect slyly agai
|
|
ven packages wake quickly. regu
|
|
y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d
|
|
y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special
|
|
(6 rows)
|
|
|
|
SET search_path TO citus_mx_test_schema;
|
|
SELECT * FROM nation_hash_collation_search_path ORDER BY 1 DESC;
|
|
n_nationkey | n_name | n_regionkey | n_comment
|
|
-------------+---------------------------+-------------+-------------------------------------------------------------------------------------------------------------
|
|
5 | ETHIOPIA | 0 | ven packages wake quickly. regu
|
|
4 | EGYPT | 4 | y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d
|
|
3 | CANADA | 1 | eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold
|
|
2 | BRAZIL | 1 | y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special
|
|
1 | ARGENTINA | 1 | al foxes promise slyly according to the regular accounts. bold requests alon
|
|
0 | ALGERIA | 0 | haggle. carefully final deposits detect slyly agai
|
|
(6 rows)
|
|
|
|
SELECT n_comment FROM nation_hash_collation_search_path ORDER BY n_comment COLLATE english;
|
|
n_comment
|
|
-------------------------------------------------------------------------------------------------------------
|
|
al foxes promise slyly according to the regular accounts. bold requests alon
|
|
eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold
|
|
haggle. carefully final deposits detect slyly agai
|
|
ven packages wake quickly. regu
|
|
y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d
|
|
y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special
|
|
(6 rows)
|
|
|
|
SELECT * FROM citus_mx_test_schema.nation_hash_composite_types WHERE test_col = '(a,a)'::citus_mx_test_schema.new_composite_type ORDER BY 1::int DESC;
|
|
n_nationkey | n_name | n_regionkey | n_comment | test_col
|
|
-------------+---------------------------+-------------+----------------------------------------------------+----------
|
|
0 | ALGERIA | 0 | haggle. carefully final deposits detect slyly agai | (a,a)
|
|
(1 row)
|
|
|
|
--test with search_path is set
|
|
SET search_path TO citus_mx_test_schema;
|
|
SELECT * FROM nation_hash_composite_types WHERE test_col = '(a,a)'::new_composite_type ORDER BY 1::int DESC;
|
|
n_nationkey | n_name | n_regionkey | n_comment | test_col
|
|
-------------+---------------------------+-------------+----------------------------------------------------+----------
|
|
0 | ALGERIA | 0 | haggle. carefully final deposits detect slyly agai | (a,a)
|
|
(1 row)
|
|
|
|
-- check when search_path is public,
|
|
-- join of two tables which are in different schemas,
|
|
-- join on partition column
|
|
SET search_path TO public;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
citus_mx_test_schema_join_1.nation_hash n1, citus_mx_test_schema_join_2.nation_hash n2
|
|
WHERE
|
|
n1.n_nationkey = n2.n_nationkey;
|
|
count
|
|
-------
|
|
25
|
|
(1 row)
|
|
|
|
-- check when search_path is different than public,
|
|
-- join of two tables which are in different schemas,
|
|
-- join on partition column
|
|
SET search_path TO citus_mx_test_schema_join_1;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
nation_hash n1, citus_mx_test_schema_join_2.nation_hash n2
|
|
WHERE
|
|
n1.n_nationkey = n2.n_nationkey;
|
|
count
|
|
-------
|
|
25
|
|
(1 row)
|
|
|
|
-- check when search_path is public,
|
|
-- join of two tables which are in same schemas,
|
|
-- join on partition column
|
|
SET search_path TO public;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
citus_mx_test_schema_join_1.nation_hash n1, citus_mx_test_schema_join_1.nation_hash_2 n2
|
|
WHERE
|
|
n1.n_nationkey = n2.n_nationkey;
|
|
count
|
|
-------
|
|
25
|
|
(1 row)
|
|
|
|
-- check when search_path is different than public,
|
|
-- join of two tables which are in same schemas,
|
|
-- join on partition column
|
|
SET search_path TO citus_mx_test_schema_join_1;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
nation_hash n1, nation_hash_2 n2
|
|
WHERE
|
|
n1.n_nationkey = n2.n_nationkey;
|
|
count
|
|
-------
|
|
25
|
|
(1 row)
|
|
|
|
-- single repartition joins
|
|
SET citus.task_executor_type TO "task-tracker";
|
|
-- check when search_path is public,
|
|
-- join of two tables which are in different schemas,
|
|
-- join on partition column and non-partition column
|
|
--SET search_path TO public;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
citus_mx_test_schema_join_1.nation_hash n1, citus_mx_test_schema_join_2.nation_hash n2
|
|
WHERE
|
|
n1.n_nationkey = n2.n_regionkey;
|
|
count
|
|
-------
|
|
25
|
|
(1 row)
|
|
|
|
-- check when search_path is different than public,
|
|
-- join of two tables which are in different schemas,
|
|
-- join on partition column and non-partition column
|
|
SET search_path TO citus_mx_test_schema_join_1;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
nation_hash n1, citus_mx_test_schema_join_2.nation_hash n2
|
|
WHERE
|
|
n1.n_nationkey = n2.n_regionkey;
|
|
count
|
|
-------
|
|
25
|
|
(1 row)
|
|
|
|
-- check when search_path is different than public,
|
|
-- join of two tables which are in same schemas,
|
|
-- join on partition column and non-partition column
|
|
SET search_path TO citus_mx_test_schema_join_1;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
nation_hash n1, nation_hash_2 n2
|
|
WHERE
|
|
n1.n_nationkey = n2.n_regionkey;
|
|
count
|
|
-------
|
|
25
|
|
(1 row)
|
|
|
|
-- hash repartition joins
|
|
-- check when search_path is public,
|
|
-- join of two tables which are in different schemas,
|
|
-- join on non-partition column
|
|
SET search_path TO public;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
citus_mx_test_schema_join_1.nation_hash n1, citus_mx_test_schema_join_2.nation_hash n2
|
|
WHERE
|
|
n1.n_regionkey = n2.n_regionkey;
|
|
count
|
|
-------
|
|
125
|
|
(1 row)
|
|
|
|
-- check when search_path is different than public,
|
|
-- join of two tables which are in different schemas,
|
|
-- join on non-partition column
|
|
SET search_path TO citus_mx_test_schema_join_1;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
nation_hash n1, citus_mx_test_schema_join_2.nation_hash n2
|
|
WHERE
|
|
n1.n_regionkey = n2.n_regionkey;
|
|
count
|
|
-------
|
|
125
|
|
(1 row)
|
|
|
|
-- check when search_path is different than public,
|
|
-- join of two tables which are in same schemas,
|
|
-- join on non-partition column
|
|
SET search_path TO citus_mx_test_schema_join_1;
|
|
SELECT
|
|
count (*)
|
|
FROM
|
|
nation_hash n1, nation_hash_2 n2
|
|
WHERE
|
|
n1.n_regionkey = n2.n_regionkey;
|
|
count
|
|
-------
|
|
125
|
|
(1 row)
|
|
|
|
-- set task_executor back to real-time
|
|
SET citus.task_executor_type TO "real-time";
|