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 aed1520d29ffed4c73abb47ba7f8e11cefe8a596
Author: QingMa <[email protected]>
AuthorDate: Fri Mar 3 10:24:54 2023 +0800

    Fix hang of multi-dqa with filter in planner (#14950)
    
    QE will hang in `ExecTupleSplit()` while executing the following query.
    ```
    select DQA_1(expr1) filter (subquery1), DQA_2(expr2) ...
    ```
    If a tuple is filtered out by DQA_1's filter, `filter_out` will be set to 
true.
    Because dqa2 has no filters, `filter_out` will not be set to false on the 
next
    loop. Then it's an endless loop.
    
    The solution is simple, if current Expr has no filter, set `filter_out` to 
false.
---
 src/backend/executor/nodeTupleSplit.c          | 7 +++----
 src/test/regress/expected/gp_dqa.out           | 7 +++++++
 src/test/regress/expected/gp_dqa_optimizer.out | 9 +++++++++
 src/test/regress/sql/gp_dqa.sql                | 3 +++
 4 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/backend/executor/nodeTupleSplit.c 
b/src/backend/executor/nodeTupleSplit.c
index a2ab695291..19a6b49c25 100644
--- a/src/backend/executor/nodeTupleSplit.c
+++ b/src/backend/executor/nodeTupleSplit.c
@@ -202,12 +202,11 @@ ExecTupleSplit(PlanState *pstate)
                                filter_out = true;
                        }
                        else
-                       {
-
                                filter_out = false;
-                       }
-
                }
+               else
+                       filter_out = false;
+
        } while(filter_out);
 
        /* reset the isnull array to the original state */
diff --git a/src/test/regress/expected/gp_dqa.out 
b/src/test/regress/expected/gp_dqa.out
index 30505978ab..08f4530477 100644
--- a/src/test/regress/expected/gp_dqa.out
+++ b/src/test/regress/expected/gp_dqa.out
@@ -2051,6 +2051,13 @@ select count(distinct a) filter (where a > 3),count( 
distinct b) filter (where a
     13 |     5 |  10
 (1 row)
 
+-- fix hang of multi-dqa with filter 
(https://github.com/greenplum-db/gpdb/issues/14728)
+select count(distinct a) filter (where a > 3), count(distinct b) from dqa_f1;
+ count | count 
+-------+-------
+    13 |     5
+(1 row)
+
 explain select sum(distinct a) filter (where a > 0), sum(distinct b) filter 
(where a > 0) from dqa_f1;
                                               QUERY PLAN                       
                       
 
------------------------------------------------------------------------------------------------------
diff --git a/src/test/regress/expected/gp_dqa_optimizer.out 
b/src/test/regress/expected/gp_dqa_optimizer.out
index a99bf5a3ee..1cff4210fa 100644
--- a/src/test/regress/expected/gp_dqa_optimizer.out
+++ b/src/test/regress/expected/gp_dqa_optimizer.out
@@ -2170,6 +2170,15 @@ DETAIL:  Feature not supported: Aggregate functions with 
FILTER
     13 |     5 |  10
 (1 row)
 
+-- fix hang of multi-dqa with filter 
(https://github.com/greenplum-db/gpdb/issues/14728)
+select count(distinct a) filter (where a > 3), count(distinct b) from dqa_f1;
+INFO:  GPORCA failed to produce a plan, falling back to planner
+DETAIL:  Feature not supported: Aggregate functions with FILTER
+ count | count 
+-------+-------
+    13 |     5
+(1 row)
+
 explain select sum(distinct a) filter (where a > 0), sum(distinct b) filter 
(where a > 0) from dqa_f1;
 INFO:  GPORCA failed to produce a plan, falling back to planner
 DETAIL:  Feature not supported: Aggregate functions with FILTER
diff --git a/src/test/regress/sql/gp_dqa.sql b/src/test/regress/sql/gp_dqa.sql
index 9bbdf48c19..1b6c2acb25 100644
--- a/src/test/regress/sql/gp_dqa.sql
+++ b/src/test/regress/sql/gp_dqa.sql
@@ -339,6 +339,9 @@ select sum(distinct a) filter (where a in (select x from 
dqa_f2 where x = a)), s
 
 select count(distinct a) filter (where a > 3),count( distinct b) filter (where 
a > 4), sum(distinct b) filter( where a > 4) from dqa_f1;
 
+-- fix hang of multi-dqa with filter 
(https://github.com/greenplum-db/gpdb/issues/14728)
+select count(distinct a) filter (where a > 3), count(distinct b) from dqa_f1;
+
 explain select sum(distinct a) filter (where a > 0), sum(distinct b) filter 
(where a > 0) from dqa_f1;
 
 explain select sum(distinct a) filter (where a > 0), sum(distinct b) filter 
(where a > 0) from dqa_f1 group by b;


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

Reply via email to