This is an automated email from the ASF dual-hosted git repository.

yjhjstz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 4be1bf50eab09cf7a0c9b2478358ba7ff8594f91
Author: Heikki Linnakangas <[email protected]>
AuthorDate: Wed Nov 2 04:10:48 2022 +0200

    Remove unnecessary code that dealt with locus of UNION plans. (#10879)
    
    The effort was duplicated with set_append_path_locus(), which is called
    from create_append_path(). Let's just let set_append_path_locus() deal
    with it.
    
    Reviewed-by: Haotian Chen <[email protected]>
    Reviewed-by: Zhenghua Lyu <[email protected]>
---
 src/backend/optimizer/prep/prepunion.c    | 24 +-----------------------
 src/test/regress/expected/with_clause.out | 28 +++++++++++++---------------
 2 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/src/backend/optimizer/prep/prepunion.c 
b/src/backend/optimizer/prep/prepunion.c
index 5656e4dbcd..fda13f0924 100644
--- a/src/backend/optimizer/prep/prepunion.c
+++ b/src/backend/optimizer/prep/prepunion.c
@@ -597,7 +597,6 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo 
*root,
        List       *tlist_list;
        List       *tlist;
        Path       *path;
-       GpSetOpType optype = PSETOP_NONE; /* CDB */
 
        /*
         * If plain UNION, tell children to fetch all tuples.
@@ -661,39 +660,18 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo 
*root,
        result_rel->reltarget = create_pathtarget(root, tlist);
        result_rel->consider_parallel = consider_parallel;
 
-
-       /* GPDB_96_MERGE_FIXME: We should use the new pathified upper planner
-        * infrastructure for this. I think we should create multiple Paths,
-        * representing different kinds of PSETOP_* implementations, and
-        * let the "add_path()" choose the cheapest one.
-        */
-       /* CDB: Decide on approach, condition argument plans to suit. */
-       if ( Gp_role == GP_ROLE_DISPATCH )
-       {
-               optype = choose_setop_type(pathlist);
-               adjust_setop_arguments(root, pathlist, tlist_list, optype);
-       }
-       else if (Gp_role == GP_ROLE_UTILITY ||
-               Gp_role == GP_ROLE_EXECUTE) /* MPP-2928 */
-       {
-               optype = PSETOP_SEQUENTIAL_QD;
-       }
-
        /*
         * Append the child results together.
         */
        path = (Path *) create_append_path(root, result_rel, pathlist, NIL,
                                                                           NIL, 
NULL, 0, false, -1);
-       // GPDB_96_MERGE_FIXME: Where should this go now?
-       //mark_append_locus(plan, optype); /* CDB: Mark the plan result locus. 
*/
-
        /*
         * For UNION ALL, we just need the Append path.  For UNION, need to add
         * node(s) to remove duplicates.
         */
        if (!op->all)
        {
-               if ( optype == PSETOP_PARALLEL_PARTITIONED )
+               if (CdbPathLocus_IsPartitioned(path->locus))
                {
                        /* CDB: Hash motion to collocate non-distinct tuples. */
                        path = make_motion_hash_all_targets(root, path, tlist);
diff --git a/src/test/regress/expected/with_clause.out 
b/src/test/regress/expected/with_clause.out
index 018235254d..c2610c7d6d 100644
--- a/src/test/regress/expected/with_clause.out
+++ b/src/test/regress/expected/with_clause.out
@@ -2263,10 +2263,10 @@ UNION ALL
 SELECT count(a1.i)
   FROM a1
   INNER JOIN a2 ON a2.i = a1.i;
-                                    QUERY PLAN                                 
   
-----------------------------------------------------------------------------------
- Gather Motion 3:1  (slice1; segments: 3)
-   ->  Append
+                              QUERY PLAN                              
+----------------------------------------------------------------------
+ Append
+   ->  Gather Motion 3:1  (slice1; segments: 3)
          ->  Subquery Scan on "*SELECT* 1"
                ->  Hash Join
                      Hash Cond: (share1_ref1.i = a2.i)
@@ -2276,18 +2276,16 @@ SELECT count(a1.i)
                            ->  Subquery Scan on a2
                                  ->  Shared Scan (share slice:id 1:0)
                                        ->  Seq Scan on foo foo_1
-         ->  Redistribute Motion 1:3  (slice2; segments: 1)
-               Hash Key: (count(share1_ref2.i))
-               ->  Aggregate
-                     ->  Gather Motion 3:1  (slice3; segments: 3)
-                           ->  Hash Join
-                                 Hash Cond: (share1_ref2.i = a2_1.i)
-                                 ->  Shared Scan (share slice:id 3:1)
-                                 ->  Hash
-                                       ->  Subquery Scan on a2_1
-                                             ->  Shared Scan (share slice:id 
3:0)
+   ->  Aggregate
+         ->  Gather Motion 3:1  (slice2; segments: 3)
+               ->  Hash Join
+                     Hash Cond: (share1_ref2.i = a2_1.i)
+                     ->  Shared Scan (share slice:id 2:1)
+                     ->  Hash
+                           ->  Subquery Scan on a2_1
+                                 ->  Shared Scan (share slice:id 2:0)
  Optimizer: Postgres query optimizer
-(22 rows)
+(20 rows)
 
 -- Another cross-slice ShareInputScan test. There is one producing slice,
 -- and two consumers in second slice. Make sure the Share Input Scan


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to