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

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

commit c34428846e0b290e6cf6fb56e973c52b850ebc4e
Author: David Kimura <[email protected]>
AuthorDate: Mon Aug 15 13:43:28 2022 -0700

    Fix assert op executor node (#13900)
    
    AssertOp is used by ORCA for run-time assertion checking. For example,
    it guarantees that the following query will not violate implicit
    cardinality constraints (i.e. foo cannot contain more than 1 row):
    
      ```
      CREATE TABLE foo(a int);
      CREATE TABLE bar(b int);
    
      SELECT * FROM foo WHERE (SELECT a FROM foo) IN (SELECT b FROM bar);
      ```
    
    PLANNER handles that check in the executor subplan node where it can
    determine if the subquery is used in an expression sublink where it
    should only return 1 row. However, this is not sufficient for ORCA which
    may generate de-correlated plan that contains a join node instead of a
    subplan node.
    
    Postgres 12 merge commit 2e653c6e54b disabled this feature in ORCA so
    that implementation may be fixed at a later date. This commit does that.
---
 .../regress/expected/bfv_statistic_optimizer.out   |  2 -
 .../regress/expected/partition_prune_optimizer.out |  4 +-
 src/test/regress/expected/update_gp.out            | 20 +++---
 src/test/regress/expected/update_gp_optimizer.out  | 78 +++++++++++-----------
 4 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/src/test/regress/expected/bfv_statistic_optimizer.out 
b/src/test/regress/expected/bfv_statistic_optimizer.out
index 43e0a2de3c..f3550401f1 100644
--- a/src/test/regress/expected/bfv_statistic_optimizer.out
+++ b/src/test/regress/expected/bfv_statistic_optimizer.out
@@ -488,8 +488,6 @@ FROM duplicate_memo_group_test_t1
      LEFT OUTER JOIN duplicate_memo_group_test_t3 a4 ON a1.c3 = a4.c3
 ) AS column2
 FROM duplicate_memo_group_test_t3 a2;
-INFO:  GPORCA failed to produce a plan, falling back to planner
-DETAIL:  DXL-to-PlStmt Translation: Assert not supported
  column1 | column2 
 ---------+---------
 (0 rows)
diff --git a/src/test/regress/expected/partition_prune_optimizer.out 
b/src/test/regress/expected/partition_prune_optimizer.out
index 7c9c1bcdd0..69572e75df 100644
--- a/src/test/regress/expected/partition_prune_optimizer.out
+++ b/src/test/regress/expected/partition_prune_optimizer.out
@@ -3322,7 +3322,7 @@ select * from boolp where a = (select value from 
boolvalues where value);
                                  ->  Seq Scan on boolvalues (actual rows=1 
loops=1)
                                        Filter: value
                                        Rows Removed by Filter: 1
-         ->  Hash (actual rows=0 loops=1)
+         ->  Hash (never executed)
                Buckets: 262144  Batches: 1  Memory Usage: 2048kB
                ->  Broadcast Motion 3:3  (slice4; segments: 3) (actual rows=0 
loops=1)
                      ->  Dynamic Seq Scan on boolp (actual rows=0 loops=1)
@@ -3346,7 +3346,7 @@ select * from boolp where a = (select value from 
boolvalues where not value);
                                  ->  Seq Scan on boolvalues (actual rows=1 
loops=1)
                                        Filter: (NOT value)
                                        Rows Removed by Filter: 1
-         ->  Hash (actual rows=0 loops=1)
+         ->  Hash (never executed)
                Buckets: 262144  Batches: 1  Memory Usage: 2048kB
                ->  Broadcast Motion 3:3  (slice4; segments: 3) (actual rows=0 
loops=1)
                      ->  Dynamic Seq Scan on boolp (actual rows=0 loops=1)
diff --git a/src/test/regress/expected/update_gp.out 
b/src/test/regress/expected/update_gp.out
index 7535120a8e..f8d47b7775 100644
--- a/src/test/regress/expected/update_gp.out
+++ b/src/test/regress/expected/update_gp.out
@@ -107,34 +107,34 @@ WHERE t1.user_vie_project_code_pk = 
keo1.user_vie_project_code_pk;
                                                  QUERY PLAN                    
                              
 
-------------------------------------------------------------------------------------------------------------
  Update on keo1
-   InitPlan 3 (returns $2)  (slice5)
+   InitPlan 3 (returns $2)  (slice1)
      ->  Aggregate
-           InitPlan 2 (returns $1)  (slice7)
-             ->  Gather Motion 3:1  (slice8; segments: 3)
-                   InitPlan 1 (returns $0)  (slice9)
+           InitPlan 2 (returns $1)  (slice3)
+             ->  Gather Motion 3:1  (slice4; segments: 3)
+                   InitPlan 1 (returns $0)  (slice5)
                      ->  Aggregate
-                           ->  Gather Motion 3:1  (slice10; segments: 3)
+                           ->  Gather Motion 3:1  (slice6; segments: 3)
                                  ->  Seq Scan on keo4
                    ->  Seq Scan on keo4 keo4_1
                          Filter: ((keo_para_budget_date)::text = $0)
-           ->  Gather Motion 3:1  (slice6; segments: 3)
+           ->  Gather Motion 3:1  (slice2; segments: 3)
                  ->  Seq Scan on keo3
                        Filter: ((bky_per)::text = ($1)::text)
-   ->  Explicit Redistribute Motion 3:3  (slice1; segments: 3)
+   ->  Explicit Redistribute Motion 3:3  (slice7; segments: 3)
          ->  Hash Join
                Hash Cond: ((a.user_vie_project_code_pk)::text = 
(b.projects_pk)::text)
                ->  Hash Join
                      Hash Cond: ((a.user_vie_project_code_pk)::text = 
(keo1.user_vie_project_code_pk)::text)
-                     ->  Redistribute Motion 3:3  (slice2; segments: 3)
+                     ->  Redistribute Motion 3:3  (slice8; segments: 3)
                            Hash Key: a.user_vie_project_code_pk
                            ->  Seq Scan on keo1 a
                                  Filter: 
((user_vie_fiscal_year_period_sk)::text = $2)
                      ->  Hash
-                           ->  Redistribute Motion 3:3  (slice3; segments: 3)
+                           ->  Redistribute Motion 3:3  (slice9; segments: 3)
                                  Hash Key: keo1.user_vie_project_code_pk
                                  ->  Seq Scan on keo1
                ->  Hash
-                     ->  Redistribute Motion 3:3  (slice4; segments: 3)
+                     ->  Redistribute Motion 3:3  (slice10; segments: 3)
                            Hash Key: b.projects_pk
                            ->  Seq Scan on keo2 b
  Optimizer: Postgres query optimizer
diff --git a/src/test/regress/expected/update_gp_optimizer.out 
b/src/test/regress/expected/update_gp_optimizer.out
index 1e59baaa29..9bb4909651 100644
--- a/src/test/regress/expected/update_gp_optimizer.out
+++ b/src/test/regress/expected/update_gp_optimizer.out
@@ -122,46 +122,48 @@ EXPLAIN (COSTS OFF) UPDATE keo1 SET 
user_vie_act_cntr_marg_cum = 234.682 FROM
                 (SELECT min (keo4.keo_para_budget_date) FROM keo4)))
     ) t1
 WHERE t1.user_vie_project_code_pk = keo1.user_vie_project_code_pk;
-                                                                               
  QUERY PLAN                                                                    
              
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+                                                                               
        QUERY PLAN                                                              
                          
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Update on keo1
-   ->  Hash Join
-         Hash Cond: ((keo1_1.user_vie_project_code_pk)::text = 
(keo1_2.user_vie_project_code_pk)::text)
-         ->  Seq Scan on keo1 keo1_1
-         ->  Hash
-               ->  Broadcast Motion 3:3  (slice1; segments: 3)
-                     ->  Hash Join
-                           Hash Cond: ((keo1_2.user_vie_project_code_pk)::text 
= (keo2.projects_pk)::text)
-                           ->  Hash Join
-                                 Hash Cond: ((max((keo3.sky_per)::text)) = 
(keo1_2.user_vie_fiscal_year_period_sk)::text)
-                                 ->  Redistribute Motion 1:3  (slice2; 
segments: 1)
-                                       ->  Aggregate
-                                             ->  Hash Join
-                                                   Hash Cond: 
((keo3.bky_per)::text = (keo4_1.keo_para_required_period)::text)
-                                                   ->  Gather Motion 3:1  
(slice3; segments: 3)
-                                                         ->  Seq Scan on keo3
-                                                   ->  Hash
-                                                         ->  Assert
-                                                               Assert Cond: 
((row_number() OVER (?)) = 1)
-                                                               ->  WindowAgg
-                                                                     ->  
Gather Motion 3:1  (slice4; segments: 3)
-                                                                           ->  
Hash Join
-                                                                               
  Hash Cond: ((min((keo4.keo_para_budget_date)::text)) = 
(keo4_1.keo_para_budget_date)::text)
-                                                                               
  ->  Redistribute Motion 1:3  (slice5; segments: 1)
-                                                                               
        ->  Aggregate
-                                                                               
              ->  Gather Motion 3:1  (slice6; segments: 3)
-                                                                               
                    ->  Seq Scan on keo4
-                                                                               
  ->  Hash
-                                                                               
        ->  Broadcast Motion 3:3  (slice7; segments: 3)
-                                                                               
              ->  Seq Scan on keo4 keo4_1
-                                 ->  Hash
-                                       ->  Broadcast Motion 3:3  (slice8; 
segments: 3)
-                                             ->  Seq Scan on keo1 keo1_2
-                           ->  Hash
-                                 ->  Broadcast Motion 3:3  (slice9; segments: 
3)
-                                       ->  Seq Scan on keo2
+   ->  Result
+         ->  Split
+               ->  Hash Join
+                     Hash Cond: ((keo1_1.user_vie_project_code_pk)::text = 
(keo1_2.user_vie_project_code_pk)::text)
+                     ->  Seq Scan on keo1 keo1_1
+                     ->  Hash
+                           ->  Broadcast Motion 3:3  (slice1; segments: 3)
+                                 ->  Hash Join
+                                       Hash Cond: 
((keo1_2.user_vie_project_code_pk)::text = (keo2.projects_pk)::text)
+                                       ->  Hash Join
+                                             Hash Cond: 
((max((keo3.sky_per)::text)) = (keo1_2.user_vie_fiscal_year_period_sk)::text)
+                                             ->  Redistribute Motion 1:3  
(slice2; segments: 1)
+                                                   ->  Aggregate
+                                                         ->  Hash Join
+                                                               Hash Cond: 
((keo3.bky_per)::text = (keo4_1.keo_para_required_period)::text)
+                                                               ->  Gather 
Motion 3:1  (slice3; segments: 3)
+                                                                     ->  Seq 
Scan on keo3
+                                                               ->  Hash
+                                                                     ->  Assert
+                                                                           
Assert Cond: ((row_number() OVER (?)) = 1)
+                                                                           ->  
WindowAgg
+                                                                               
  ->  Gather Motion 3:1  (slice4; segments: 3)
+                                                                               
        ->  Hash Join
+                                                                               
              Hash Cond: ((min((keo4.keo_para_budget_date)::text)) = 
(keo4_1.keo_para_budget_date)::text)
+                                                                               
              ->  Redistribute Motion 1:3  (slice5; segments: 1)
+                                                                               
                    ->  Aggregate
+                                                                               
                          ->  Gather Motion 3:1  (slice6; segments: 3)
+                                                                               
                                ->  Seq Scan on keo4
+                                                                               
              ->  Hash
+                                                                               
                    ->  Broadcast Motion 3:3  (slice7; segments: 3)
+                                                                               
                          ->  Seq Scan on keo4 keo4_1
+                                             ->  Hash
+                                                   ->  Broadcast Motion 3:3  
(slice8; segments: 3)
+                                                         ->  Seq Scan on keo1 
keo1_2
+                                       ->  Hash
+                                             ->  Broadcast Motion 3:3  
(slice9; segments: 3)
+                                                   ->  Seq Scan on keo2
  Optimizer: Pivotal Optimizer (GPORCA)
-(37 rows)
+(39 rows)
 
 UPDATE keo1 SET user_vie_act_cntr_marg_cum = 234.682 FROM
     ( SELECT a.user_vie_project_code_pk FROM keo1 a INNER JOIN keo2 b


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

Reply via email to