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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 1711676e3ecc6faa579f410ec749e114bcf86695
Author: morrySnow <101034200+morrys...@users.noreply.github.com>
AuthorDate: Wed Jul 5 15:44:40 2023 +0800

    [fix](Nereids) set operation physical properties derive is wrong (#21496)
---
 .../properties/ChildOutputPropertyDeriver.java     |   2 +-
 .../nereids/properties/RequestPropertyDeriver.java |   2 +-
 .../nereids_tpcds_shape_sf100_p0/shape/query49.out | 132 ++++++++++-----------
 .../nereids_tpcds_shape_sf100_p0/shape/query75.out | 108 +++++++++--------
 4 files changed, 120 insertions(+), 124 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
index 158eaa67f2..316f31a0f3 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
@@ -345,7 +345,7 @@ public class ChildOutputPropertyDeriver extends 
PlanVisitor<PhysicalProperties,
             for (int j = 0; j < setOperation.getChildOutput(i).size(); j++) {
                 int offset = distributionSpecHash.getExprIdToEquivalenceSet()
                         
.getOrDefault(setOperation.getChildOutput(i).get(j).getExprId(), -1);
-                if (offset > 0) {
+                if (offset >= 0) {
                     offsetsOfCurrentChild[offset] = j;
                 } else {
                     return PhysicalProperties.ANY;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java
index 74324101d3..9b223e1a53 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java
@@ -229,7 +229,7 @@ public class RequestPropertyDeriver extends 
PlanVisitor<Void, PlanContext> {
         for (int i = 0; i < setOperationOutputs.size(); i++) {
             int offset = 
distributionRequestFromParent.getExprIdToEquivalenceSet()
                     .getOrDefault(setOperationOutputs.get(i).getExprId(), -1);
-            if (offset > 0) {
+            if (offset >= 0) {
                 outputOffsets[offset] = i;
             }
         }
diff --git 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query49.out 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query49.out
index c9f23c7fd0..188d6d3c7b 100644
--- a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query49.out
+++ b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query49.out
@@ -3,86 +3,84 @@
 PhysicalTopN
 --PhysicalDistribute
 ----PhysicalTopN
-------hashAgg[GLOBAL]
---------PhysicalDistribute
-----------hashAgg[LOCAL]
-------------PhysicalUnion
---------------PhysicalDistribute
-----------------PhysicalProject
-------------------filter(((return_rank <= 10) OR (currency_rank <= 10)))
+------hashAgg[LOCAL]
+--------PhysicalUnion
+----------PhysicalDistribute
+------------PhysicalProject
+--------------filter(((return_rank <= 10) OR (currency_rank <= 10)))
+----------------PhysicalWindow
+------------------PhysicalQuickSort
 --------------------PhysicalWindow
 ----------------------PhysicalQuickSort
-------------------------PhysicalWindow
+------------------------PhysicalDistribute
 --------------------------PhysicalQuickSort
-----------------------------PhysicalDistribute
-------------------------------PhysicalQuickSort
---------------------------------PhysicalProject
-----------------------------------hashAgg[GLOBAL]
-------------------------------------PhysicalDistribute
---------------------------------------hashAgg[LOCAL]
+----------------------------PhysicalProject
+------------------------------hashAgg[GLOBAL]
+--------------------------------PhysicalDistribute
+----------------------------------hashAgg[LOCAL]
+------------------------------------PhysicalProject
+--------------------------------------hashJoin[INNER_JOIN](ws.ws_order_number 
= wr.wr_order_number)(item = wr.wr_item_sk)
 ----------------------------------------PhysicalProject
-------------------------------------------hashJoin[INNER_JOIN](ws.ws_order_number
 = wr.wr_order_number)(item = wr.wr_item_sk)
+------------------------------------------filter((wr.wr_return_amt > 10000.00))
+--------------------------------------------PhysicalOlapScan[web_returns]
+----------------------------------------hashJoin[INNER_JOIN](ws.ws_sold_date_sk
 = date_dim.d_date_sk)
+------------------------------------------PhysicalProject
+--------------------------------------------filter((ws.ws_net_paid > 
0.00)(ws.ws_quantity > 0)(ws.ws_net_profit > 1.00))
+----------------------------------------------PhysicalOlapScan[web_sales]
+------------------------------------------PhysicalDistribute
 --------------------------------------------PhysicalProject
-----------------------------------------------filter((wr.wr_return_amt > 
10000.00))
-------------------------------------------------PhysicalOlapScan[web_returns]
---------------------------------------------hashJoin[INNER_JOIN](ws.ws_sold_date_sk
 = date_dim.d_date_sk)
-----------------------------------------------PhysicalProject
-------------------------------------------------filter((ws.ws_net_paid > 
0.00)(ws.ws_quantity > 0)(ws.ws_net_profit > 1.00))
---------------------------------------------------PhysicalOlapScan[web_sales]
-----------------------------------------------PhysicalDistribute
-------------------------------------------------PhysicalProject
---------------------------------------------------filter((date_dim.d_moy = 
12)(date_dim.d_year = 1999))
-----------------------------------------------------PhysicalOlapScan[date_dim]
---------------PhysicalDistribute
-----------------PhysicalProject
-------------------filter(((return_rank <= 10) OR (currency_rank <= 10)))
+----------------------------------------------filter((date_dim.d_moy = 
12)(date_dim.d_year = 1999))
+------------------------------------------------PhysicalOlapScan[date_dim]
+----------PhysicalDistribute
+------------PhysicalProject
+--------------filter(((return_rank <= 10) OR (currency_rank <= 10)))
+----------------PhysicalWindow
+------------------PhysicalQuickSort
 --------------------PhysicalWindow
 ----------------------PhysicalQuickSort
-------------------------PhysicalWindow
+------------------------PhysicalDistribute
 --------------------------PhysicalQuickSort
-----------------------------PhysicalDistribute
-------------------------------PhysicalQuickSort
---------------------------------PhysicalProject
-----------------------------------hashAgg[GLOBAL]
-------------------------------------PhysicalDistribute
---------------------------------------hashAgg[LOCAL]
+----------------------------PhysicalProject
+------------------------------hashAgg[GLOBAL]
+--------------------------------PhysicalDistribute
+----------------------------------hashAgg[LOCAL]
+------------------------------------PhysicalProject
+--------------------------------------hashJoin[INNER_JOIN](cs.cs_order_number 
= cr.cr_order_number)(item = cr.cr_item_sk)
 ----------------------------------------PhysicalProject
-------------------------------------------hashJoin[INNER_JOIN](cs.cs_order_number
 = cr.cr_order_number)(item = cr.cr_item_sk)
+------------------------------------------filter((cr.cr_return_amount > 
10000.00))
+--------------------------------------------PhysicalOlapScan[catalog_returns]
+----------------------------------------hashJoin[INNER_JOIN](cs.cs_sold_date_sk
 = date_dim.d_date_sk)
+------------------------------------------PhysicalProject
+--------------------------------------------filter((cs.cs_net_paid > 
0.00)(cs.cs_quantity > 0)(cs.cs_net_profit > 1.00))
+----------------------------------------------PhysicalOlapScan[catalog_sales]
+------------------------------------------PhysicalDistribute
 --------------------------------------------PhysicalProject
-----------------------------------------------filter((cr.cr_return_amount > 
10000.00))
-------------------------------------------------PhysicalOlapScan[catalog_returns]
---------------------------------------------hashJoin[INNER_JOIN](cs.cs_sold_date_sk
 = date_dim.d_date_sk)
-----------------------------------------------PhysicalProject
-------------------------------------------------filter((cs.cs_net_paid > 
0.00)(cs.cs_quantity > 0)(cs.cs_net_profit > 1.00))
---------------------------------------------------PhysicalOlapScan[catalog_sales]
-----------------------------------------------PhysicalDistribute
-------------------------------------------------PhysicalProject
---------------------------------------------------filter((date_dim.d_moy = 
12)(date_dim.d_year = 1999))
-----------------------------------------------------PhysicalOlapScan[date_dim]
---------------PhysicalDistribute
-----------------PhysicalProject
-------------------filter(((return_rank <= 10) OR (currency_rank <= 10)))
+----------------------------------------------filter((date_dim.d_moy = 
12)(date_dim.d_year = 1999))
+------------------------------------------------PhysicalOlapScan[date_dim]
+----------PhysicalDistribute
+------------PhysicalProject
+--------------filter(((return_rank <= 10) OR (currency_rank <= 10)))
+----------------PhysicalWindow
+------------------PhysicalQuickSort
 --------------------PhysicalWindow
 ----------------------PhysicalQuickSort
-------------------------PhysicalWindow
+------------------------PhysicalDistribute
 --------------------------PhysicalQuickSort
-----------------------------PhysicalDistribute
-------------------------------PhysicalQuickSort
---------------------------------PhysicalProject
-----------------------------------hashAgg[GLOBAL]
-------------------------------------PhysicalDistribute
---------------------------------------hashAgg[LOCAL]
+----------------------------PhysicalProject
+------------------------------hashAgg[GLOBAL]
+--------------------------------PhysicalDistribute
+----------------------------------hashAgg[LOCAL]
+------------------------------------PhysicalProject
+--------------------------------------hashJoin[INNER_JOIN](sts.ss_ticket_number
 = sr.sr_ticket_number)(item = sr.sr_item_sk)
 ----------------------------------------PhysicalProject
-------------------------------------------hashJoin[INNER_JOIN](sts.ss_ticket_number
 = sr.sr_ticket_number)(item = sr.sr_item_sk)
+------------------------------------------filter((sr.sr_return_amt > 10000.00))
+--------------------------------------------PhysicalOlapScan[store_returns]
+----------------------------------------hashJoin[INNER_JOIN](sts.ss_sold_date_sk
 = date_dim.d_date_sk)
+------------------------------------------PhysicalProject
+--------------------------------------------filter((sts.ss_quantity > 
0)(sts.ss_net_profit > 1.00)(sts.ss_net_paid > 0.00))
+----------------------------------------------PhysicalOlapScan[store_sales]
+------------------------------------------PhysicalDistribute
 --------------------------------------------PhysicalProject
-----------------------------------------------filter((sr.sr_return_amt > 
10000.00))
-------------------------------------------------PhysicalOlapScan[store_returns]
---------------------------------------------hashJoin[INNER_JOIN](sts.ss_sold_date_sk
 = date_dim.d_date_sk)
-----------------------------------------------PhysicalProject
-------------------------------------------------filter((sts.ss_quantity > 
0)(sts.ss_net_profit > 1.00)(sts.ss_net_paid > 0.00))
---------------------------------------------------PhysicalOlapScan[store_sales]
-----------------------------------------------PhysicalDistribute
-------------------------------------------------PhysicalProject
---------------------------------------------------filter((date_dim.d_moy = 
12)(date_dim.d_year = 1999))
-----------------------------------------------------PhysicalOlapScan[date_dim]
+----------------------------------------------filter((date_dim.d_moy = 
12)(date_dim.d_year = 1999))
+------------------------------------------------PhysicalOlapScan[date_dim]
 
diff --git 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query75.out 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query75.out
index 60e083b48a..1b278e9990 100644
--- a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query75.out
+++ b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query75.out
@@ -5,64 +5,62 @@ CteAnchor[cteId= ( CTEId#3=] )
 ----hashAgg[GLOBAL]
 ------PhysicalDistribute
 --------hashAgg[LOCAL]
-----------hashAgg[GLOBAL]
-------------PhysicalDistribute
---------------hashAgg[LOCAL]
-----------------PhysicalUnion
-------------------PhysicalDistribute
+----------hashAgg[LOCAL]
+------------PhysicalUnion
+--------------PhysicalDistribute
+----------------PhysicalProject
+------------------hashJoin[RIGHT_OUTER_JOIN](catalog_sales.cs_item_sk = 
catalog_returns.cr_item_sk)(catalog_sales.cs_order_number = 
catalog_returns.cr_order_number)
+--------------------PhysicalProject
+----------------------PhysicalOlapScan[catalog_returns]
+--------------------PhysicalProject
+----------------------hashJoin[INNER_JOIN](date_dim.d_date_sk = 
catalog_sales.cs_sold_date_sk)
+------------------------hashJoin[INNER_JOIN](item.i_item_sk = 
catalog_sales.cs_item_sk)
+--------------------------PhysicalProject
+----------------------------PhysicalOlapScan[catalog_sales]
+--------------------------PhysicalDistribute
+----------------------------PhysicalProject
+------------------------------filter((cast(i_category as VARCHAR(*)) = 'Home'))
+--------------------------------PhysicalOlapScan[item]
+------------------------PhysicalDistribute
+--------------------------PhysicalProject
+----------------------------filter(((date_dim.d_year = 1998) OR 
(date_dim.d_year = 1999)))
+------------------------------PhysicalOlapScan[date_dim]
+--------------PhysicalDistribute
+----------------PhysicalProject
+------------------hashJoin[RIGHT_OUTER_JOIN](store_sales.ss_item_sk = 
store_returns.sr_item_sk)(store_sales.ss_ticket_number = 
store_returns.sr_ticket_number)
+--------------------PhysicalProject
+----------------------PhysicalOlapScan[store_returns]
 --------------------PhysicalProject
-----------------------hashJoin[RIGHT_OUTER_JOIN](catalog_sales.cs_item_sk = 
catalog_returns.cr_item_sk)(catalog_sales.cs_order_number = 
catalog_returns.cr_order_number)
-------------------------PhysicalProject
---------------------------PhysicalOlapScan[catalog_returns]
-------------------------PhysicalProject
---------------------------hashJoin[INNER_JOIN](date_dim.d_date_sk = 
catalog_sales.cs_sold_date_sk)
-----------------------------hashJoin[INNER_JOIN](item.i_item_sk = 
catalog_sales.cs_item_sk)
-------------------------------PhysicalProject
---------------------------------PhysicalOlapScan[catalog_sales]
-------------------------------PhysicalDistribute
---------------------------------PhysicalProject
-----------------------------------filter((cast(i_category as VARCHAR(*)) = 
'Home'))
-------------------------------------PhysicalOlapScan[item]
-----------------------------PhysicalDistribute
-------------------------------PhysicalProject
---------------------------------filter(((date_dim.d_year = 1998) OR 
(date_dim.d_year = 1999)))
-----------------------------------PhysicalOlapScan[date_dim]
-------------------PhysicalDistribute
+----------------------hashJoin[INNER_JOIN](date_dim.d_date_sk = 
store_sales.ss_sold_date_sk)
+------------------------hashJoin[INNER_JOIN](item.i_item_sk = 
store_sales.ss_item_sk)
+--------------------------PhysicalProject
+----------------------------PhysicalOlapScan[store_sales]
+--------------------------PhysicalDistribute
+----------------------------PhysicalProject
+------------------------------filter((cast(i_category as VARCHAR(*)) = 'Home'))
+--------------------------------PhysicalOlapScan[item]
+------------------------PhysicalDistribute
+--------------------------PhysicalProject
+----------------------------filter(((date_dim.d_year = 1998) OR 
(date_dim.d_year = 1999)))
+------------------------------PhysicalOlapScan[date_dim]
+--------------PhysicalDistribute
+----------------PhysicalProject
+------------------hashJoin[RIGHT_OUTER_JOIN](web_sales.ws_item_sk = 
web_returns.wr_item_sk)(web_sales.ws_order_number = web_returns.wr_order_number)
 --------------------PhysicalProject
-----------------------hashJoin[RIGHT_OUTER_JOIN](store_sales.ss_item_sk = 
store_returns.sr_item_sk)(store_sales.ss_ticket_number = 
store_returns.sr_ticket_number)
-------------------------PhysicalProject
---------------------------PhysicalOlapScan[store_returns]
-------------------------PhysicalProject
---------------------------hashJoin[INNER_JOIN](date_dim.d_date_sk = 
store_sales.ss_sold_date_sk)
-----------------------------hashJoin[INNER_JOIN](item.i_item_sk = 
store_sales.ss_item_sk)
-------------------------------PhysicalProject
---------------------------------PhysicalOlapScan[store_sales]
-------------------------------PhysicalDistribute
---------------------------------PhysicalProject
-----------------------------------filter((cast(i_category as VARCHAR(*)) = 
'Home'))
-------------------------------------PhysicalOlapScan[item]
-----------------------------PhysicalDistribute
-------------------------------PhysicalProject
---------------------------------filter(((date_dim.d_year = 1998) OR 
(date_dim.d_year = 1999)))
-----------------------------------PhysicalOlapScan[date_dim]
-------------------PhysicalDistribute
+----------------------PhysicalOlapScan[web_returns]
 --------------------PhysicalProject
-----------------------hashJoin[RIGHT_OUTER_JOIN](web_sales.ws_item_sk = 
web_returns.wr_item_sk)(web_sales.ws_order_number = web_returns.wr_order_number)
-------------------------PhysicalProject
---------------------------PhysicalOlapScan[web_returns]
-------------------------PhysicalProject
---------------------------hashJoin[INNER_JOIN](date_dim.d_date_sk = 
web_sales.ws_sold_date_sk)
-----------------------------hashJoin[INNER_JOIN](item.i_item_sk = 
web_sales.ws_item_sk)
-------------------------------PhysicalProject
---------------------------------PhysicalOlapScan[web_sales]
-------------------------------PhysicalDistribute
---------------------------------PhysicalProject
-----------------------------------filter((cast(i_category as VARCHAR(*)) = 
'Home'))
-------------------------------------PhysicalOlapScan[item]
-----------------------------PhysicalDistribute
-------------------------------PhysicalProject
---------------------------------filter(((date_dim.d_year = 1998) OR 
(date_dim.d_year = 1999)))
-----------------------------------PhysicalOlapScan[date_dim]
+----------------------hashJoin[INNER_JOIN](date_dim.d_date_sk = 
web_sales.ws_sold_date_sk)
+------------------------hashJoin[INNER_JOIN](item.i_item_sk = 
web_sales.ws_item_sk)
+--------------------------PhysicalProject
+----------------------------PhysicalOlapScan[web_sales]
+--------------------------PhysicalDistribute
+----------------------------PhysicalProject
+------------------------------filter((cast(i_category as VARCHAR(*)) = 'Home'))
+--------------------------------PhysicalOlapScan[item]
+------------------------PhysicalDistribute
+--------------------------PhysicalProject
+----------------------------filter(((date_dim.d_year = 1998) OR 
(date_dim.d_year = 1999)))
+------------------------------PhysicalOlapScan[date_dim]
 --PhysicalTopN
 ----PhysicalDistribute
 ------PhysicalTopN


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to