citus/src/backend/distributed/planner
Teja Mupparti fa7b8949a8 This implements MERGE phase3
Support pushdown query where all the tables in the merge-sql are Citus-distributed, co-located, and both
the source and target relations are joined on the distribution column. This will generate multiple tasks
which execute independently after pushdown.

SELECT create_distributed_table('t1', 'id');
SELECT create_distributed_table('s1', 'id', colocate_with => ‘t1’);

MERGE INTO t1
USING s1
ON t1.id = s1.id
        WHEN MATCHED THEN
                UPDATE SET val = s1.val + 10
        WHEN MATCHED THEN
                DELETE
        WHEN NOT MATCHED THEN
                INSERT (id, val, src) VALUES (s1.id, s1.val, s1.src)

*The only exception for both the phases II and III is, UPDATEs and INSERTs must be done on the same shard-group
as the joined key; for example, below scenarios are NOT supported as the key-value to be inserted/updated is not
guaranteed to be on the same node as the id distribution-column.

MERGE INTO target t
USING source s ON (t.customer_id = s.customer_id)
WHEN NOT MATCHED THEN - -
     INSERT(customer_id, …) VALUES (<non-local-constant-key-value>, ……);

OR this scenario where we update the distribution column itself

MERGE INTO target t
USING source s On (t.customer_id = s.customer_id)
WHEN MATCHED THEN
     UPDATE SET customer_id = 100;
2023-01-24 17:44:21 -08:00
..
combine_query_planner.c verify shards if exists for insert, delete, update (#6280) 2022-09-06 15:29:14 +02:00
cte_inline.c PG15: Value -> String, Integer, Float. 2022-05-02 10:12:03 -07:00
deparse_shard_query.c Support MERGE Phase – I 2022-12-18 20:32:15 -08:00
distributed_planner.c Support MERGE on distributed tables with restrictions 2023-01-18 11:05:27 -08:00
extended_op_node_utils.c Drop postgres 11 support 2021-03-25 09:20:28 +03:00
fast_path_router_planner.c Support MERGE on distributed tables with restrictions 2023-01-18 11:05:27 -08:00
function_call_delegation.c Drop postgres 12 support (#6040) 2022-07-20 17:49:36 +03:00
insert_select_planner.c Remove unused functions (#6220) 2022-08-22 11:53:25 +03:00
intermediate_result_pruning.c Remove useless version compats 2022-07-29 10:31:55 +02:00
local_distributed_join_planner.c Phase - I: recursively plan non-recurring relations 2022-12-07 18:27:50 +03:00
local_plan_cache.c Remove useless version compats 2022-07-29 10:31:55 +02:00
multi_explain.c Fixes a bug that causes crash when using auto_explain extension with ALTER TABLE...ADD FOREIGN KEY... queries. (#6470) 2022-11-15 17:53:39 +03:00
multi_join_order.c Remove unused functions (#6220) 2022-08-22 11:53:25 +03:00
multi_logical_optimizer.c Remove useless version compats 2022-07-29 10:31:55 +02:00
multi_logical_planner.c Revert "Support JSON_TABLE on PG 15 (#6241)" 2022-09-12 15:20:17 +03:00
multi_physical_planner.c This implements MERGE phase3 2023-01-24 17:44:21 -08:00
multi_router_planner.c This implements MERGE phase3 2023-01-24 17:44:21 -08:00
planner_readme.md Fix some more master->coordinator comments 2020-07-07 10:37:53 +02:00
query_colocation_checker.c Drop postgres 11 support 2021-03-25 09:20:28 +03:00
query_pushdown_planning.c Add lateral join checks for outer joins and drop the useless ones for semi joins 2022-12-07 18:27:50 +03:00
recursive_planning.c Add lateral join checks for outer joins and drop the useless ones for semi joins 2022-12-07 18:27:50 +03:00
relation_restriction_equivalence.c Support MERGE on distributed tables with restrictions 2023-01-18 11:05:27 -08:00
shard_pruning.c Fix typo: "no sharding pruning constraints" -> "no shard pruning constraints" (#5490) 2021-11-25 21:00:44 +01:00
tdigest_extension.c adapt recently added code for pg13 2020-08-04 15:18:27 +03:00