mirror of https://github.com/citusdata/citus.git
Add additional INSERT..SELECT repartition tests
parent
9dd14fa90d
commit
64ca5c9acb
|
@ -1101,6 +1101,16 @@ SELECT create_distributed_function('dist_func(int, int)');
|
|||
(1 row)
|
||||
|
||||
SET client_min_messages TO DEBUG;
|
||||
SET citus.enable_unique_job_ids TO off;
|
||||
INSERT INTO source_table VALUES (1,2, '2020-02-02', 3, 4, 5);
|
||||
DEBUG: Creating router plan
|
||||
DEBUG: Plan is router executable
|
||||
INSERT INTO source_table VALUES (1,2, '2020-02-02', 3, 4, 5);
|
||||
DEBUG: Creating router plan
|
||||
DEBUG: Plan is router executable
|
||||
INSERT INTO source_table VALUES (3,4, '2020-02-02', 3, 4, 5);
|
||||
DEBUG: Creating router plan
|
||||
DEBUG: Plan is router executable
|
||||
INSERT INTO target_table AS enriched(c1, c2, c3, c4, c5, c6, cardinality, sum)
|
||||
SELECT c1, c2, c3, c4, -1::float AS c5,
|
||||
dist_func(c1, 4) c6,
|
||||
|
@ -1117,6 +1127,34 @@ DEBUG: INSERT target table and the source relation of the SELECT partition colu
|
|||
DEBUG: Router planner cannot handle multi-shard select queries
|
||||
DEBUG: performing repartitioned INSERT ... SELECT
|
||||
DEBUG: partitioning SELECT query by column index 0 with name 'c1'
|
||||
DEBUG: distributed statement: INSERT INTO insert_select_repartition.target_table_4213639 AS enriched (c1, c2, c3, c4, c5, c6, cardinality, sum) SELECT c1, c2, c3, c4, c5, c6, cardinality, sum FROM read_intermediate_results('{repartitioned_results_xxxxx_from_4213644_to_0}'::text[], 'binary'::citus_copy_format) intermediate_result(c1 integer, c2 integer, c3 timestamp without time zone, c4 integer, c5 integer, c6 integer[], cardinality integer, sum integer) ON CONFLICT(c1, c2, c3, c4, c5, c6) DO UPDATE SET cardinality = (enriched.cardinality OPERATOR(pg_catalog.+) excluded.cardinality), sum = (enriched.sum OPERATOR(pg_catalog.+) excluded.sum)
|
||||
DEBUG: distributed statement: INSERT INTO insert_select_repartition.target_table_4213641 AS enriched (c1, c2, c3, c4, c5, c6, cardinality, sum) SELECT c1, c2, c3, c4, c5, c6, cardinality, sum FROM read_intermediate_results('{repartitioned_results_xxxxx_from_4213645_to_2}'::text[], 'binary'::citus_copy_format) intermediate_result(c1 integer, c2 integer, c3 timestamp without time zone, c4 integer, c5 integer, c6 integer[], cardinality integer, sum integer) ON CONFLICT(c1, c2, c3, c4, c5, c6) DO UPDATE SET cardinality = (enriched.cardinality OPERATOR(pg_catalog.+) excluded.cardinality), sum = (enriched.sum OPERATOR(pg_catalog.+) excluded.sum)
|
||||
RESET client_min_messages;
|
||||
EXPLAIN (COSTS OFF) INSERT INTO target_table AS enriched(c1, c2, c3, c4, c5, c6, cardinality, sum)
|
||||
SELECT c1, c2, c3, c4, -1::float AS c5,
|
||||
dist_func(c1, 4) c6,
|
||||
sum(cardinality),
|
||||
sum(sum)
|
||||
FROM source_table
|
||||
GROUP BY c1, c2, c3, c4, c5, c6
|
||||
ON CONFLICT(c1, c2, c3, c4, c5, c6)
|
||||
DO UPDATE SET
|
||||
cardinality = enriched.cardinality + excluded.cardinality,
|
||||
sum = enriched.sum + excluded.sum;
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------
|
||||
Custom Scan (Citus INSERT ... SELECT)
|
||||
INSERT/SELECT method: repartition
|
||||
-> Custom Scan (Citus Adaptive)
|
||||
Task Count: 4
|
||||
Tasks Shown: One of 4
|
||||
-> Task
|
||||
Node: host=localhost port=xxxxx dbname=regression
|
||||
-> HashAggregate
|
||||
Group Key: c1, c2, c3, c4, '-1'::double precision, insert_select_repartition.dist_func(c1, 4)
|
||||
-> Seq Scan on source_table_4213644 source_table
|
||||
(10 rows)
|
||||
|
||||
-- clean-up
|
||||
SET client_min_messages TO WARNING;
|
||||
DROP SCHEMA insert_select_repartition CASCADE;
|
||||
|
|
|
@ -528,6 +528,11 @@ LANGUAGE plpgsql STABLE;
|
|||
SELECT create_distributed_function('dist_func(int, int)');
|
||||
|
||||
SET client_min_messages TO DEBUG;
|
||||
SET citus.enable_unique_job_ids TO off;
|
||||
INSERT INTO source_table VALUES (1,2, '2020-02-02', 3, 4, 5);
|
||||
INSERT INTO source_table VALUES (1,2, '2020-02-02', 3, 4, 5);
|
||||
INSERT INTO source_table VALUES (3,4, '2020-02-02', 3, 4, 5);
|
||||
|
||||
INSERT INTO target_table AS enriched(c1, c2, c3, c4, c5, c6, cardinality, sum)
|
||||
SELECT c1, c2, c3, c4, -1::float AS c5,
|
||||
dist_func(c1, 4) c6,
|
||||
|
@ -540,7 +545,20 @@ DO UPDATE SET
|
|||
cardinality = enriched.cardinality + excluded.cardinality,
|
||||
sum = enriched.sum + excluded.sum;
|
||||
|
||||
-- clean-up
|
||||
RESET client_min_messages;
|
||||
|
||||
EXPLAIN (COSTS OFF) INSERT INTO target_table AS enriched(c1, c2, c3, c4, c5, c6, cardinality, sum)
|
||||
SELECT c1, c2, c3, c4, -1::float AS c5,
|
||||
dist_func(c1, 4) c6,
|
||||
sum(cardinality),
|
||||
sum(sum)
|
||||
FROM source_table
|
||||
GROUP BY c1, c2, c3, c4, c5, c6
|
||||
ON CONFLICT(c1, c2, c3, c4, c5, c6)
|
||||
DO UPDATE SET
|
||||
cardinality = enriched.cardinality + excluded.cardinality,
|
||||
sum = enriched.sum + excluded.sum;
|
||||
|
||||
-- clean-up
|
||||
SET client_min_messages TO WARNING;
|
||||
DROP SCHEMA insert_select_repartition CASCADE;
|
||||
|
|
Loading…
Reference in New Issue