Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CostModelV1 extends PlanVisitor<Cost, PlanContext> {
// the penalty factor is no more than BROADCAST_JOIN_SKEW_PENALTY_LIMIT
static final double BROADCAST_JOIN_SKEW_RATIO = 30.0;
static final double BROADCAST_JOIN_SKEW_PENALTY_LIMIT = 2.0;
private int beNumber = 1;
private final int beNumber;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是测试用的变量,来自sessionVariable,为什么要final

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是在costModel初始化的时候设定的,中间不会被修改


public CostModelV1() {
if (ConnectContext.get().getSessionVariable().isPlayNereidsDump()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ private void dpHypOptimize() {
// Due to EnsureProjectOnTopJoin, root group can't be Join Group, so DPHyp doesn't change the root group
cascadesContext.pushJob(new JoinOrderJob(root, cascadesContext.getCurrentJobContext()));
cascadesContext.getJobScheduler().executeJobPool(cascadesContext);
// after DPHyp just keep logical expression
cascadesContext.getMemo().removePhysicalExpression();
cascadesContext.getStatementContext().setOtherJoinReorder(true);
}

Expand Down
26 changes: 0 additions & 26 deletions fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -116,31 +115,6 @@ public int getGroupExpressionsSize() {
return groupExpressions.size();
}

/** just keep LogicalExpression in Memo. */
public void removePhysicalExpression() {
groupExpressions.entrySet().removeIf(entry -> entry.getValue().getPlan() instanceof PhysicalPlan);

Iterator<Map.Entry<GroupId, Group>> iterator = groups.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<GroupId, Group> entry = iterator.next();
Group group = entry.getValue();

group.clearPhysicalExpressions();
group.clearLowestCostPlans();
group.removeParentPhysicalExpressions();
group.setExplored(false);

if (group.getLogicalExpressions().isEmpty() && group.getPhysicalExpressions().isEmpty()) {
iterator.remove();
}
}

// logical groupExpression reset ruleMask
groupExpressions.values().stream()
.filter(groupExpression -> groupExpression.getPlan() instanceof LogicalPlan)
.forEach(GroupExpression::clearApplied);
}

private Plan skipProject(Plan plan, Group targetGroup) {
// Some top project can't be eliminated
if (plan instanceof LogicalProject) {
Expand Down
154 changes: 78 additions & 76 deletions regression-test/data/nereids_tpcds_shape_sf1000_p0/shape/query64.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,103 +9,105 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
------------PhysicalProject
--------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_store_sk = store.s_store_sk))otherCondition=()
----------------PhysicalProject
------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = cs_ui.cs_item_sk))otherCondition=()
--------------------PhysicalDistribute
----------------------PhysicalProject
------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_first_shipto_date_sk = d3.d_date_sk))otherCondition=()
------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_promo_sk = promotion.p_promo_sk))otherCondition=()
--------------------PhysicalProject
----------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_current_cdemo_sk = cd2.cd_demo_sk))otherCondition=(( not (cd_marital_status = cd_marital_status)))
------------------------PhysicalDistribute
--------------------------PhysicalProject
----------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_first_sales_date_sk = d2.d_date_sk))otherCondition=()
----------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_first_shipto_date_sk = d3.d_date_sk))otherCondition=()
------------------------------PhysicalProject
--------------------------------hashJoin[INNER_JOIN] hashCondition=((hd2.hd_income_band_sk = ib2.ib_income_band_sk))otherCondition=()
----------------------------------PhysicalProject
------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_addr_sk = ad1.ca_address_sk))otherCondition=()
--------------------------------------PhysicalDistribute
--------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_customer_sk = customer.c_customer_sk))otherCondition=()
----------------------------------PhysicalDistribute
------------------------------------PhysicalProject
--------------------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_current_addr_sk = ad2.ca_address_sk))otherCondition=()
----------------------------------------PhysicalDistribute
------------------------------------------PhysicalProject
--------------------------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_first_sales_date_sk = d2.d_date_sk))otherCondition=()
----------------------------------------------PhysicalDistribute
------------------------------------------------PhysicalProject
--------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_current_hdemo_sk = hd2.hd_demo_sk))otherCondition=()
----------------------------------------------------PhysicalProject
------------------------------------------------------PhysicalOlapScan[customer]
----------------------------------------------------PhysicalDistribute
------------------------------------------------------PhysicalProject
--------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((hd2.hd_income_band_sk = ib2.ib_income_band_sk))otherCondition=()
----------------------------------------------------------PhysicalDistribute
------------------------------------------------------------PhysicalProject
--------------------------------------------------------------PhysicalOlapScan[household_demographics]
----------------------------------------------------------PhysicalDistribute
------------------------------------------------------------PhysicalProject
--------------------------------------------------------------PhysicalOlapScan[income_band]
----------------------------------------------PhysicalDistribute
------------------------------------------------PhysicalProject
--------------------------------------------------PhysicalOlapScan[date_dim]
----------------------------------------PhysicalDistribute
------------------------------------------PhysicalProject
--------------------------------------------PhysicalOlapScan[customer_address]
----------------------------------PhysicalDistribute
------------------------------------PhysicalProject
--------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number))otherCondition=()
----------------------------------------PhysicalProject
------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_hdemo_sk = hd1.hd_demo_sk))otherCondition=()
--------------------------------------------PhysicalProject
----------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_promo_sk = promotion.p_promo_sk))otherCondition=()
------------------------------------------PhysicalOlapScan[store_returns]
----------------------------------------PhysicalDistribute
------------------------------------------PhysicalProject
--------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = cs_ui.cs_item_sk))otherCondition=()
----------------------------------------------PhysicalDistribute
------------------------------------------------PhysicalProject
--------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_current_cdemo_sk = cd2.cd_demo_sk))otherCondition=(( not (cd_marital_status = cd_marital_status)))
--------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_addr_sk = ad1.ca_address_sk))otherCondition=()
----------------------------------------------------PhysicalDistribute
------------------------------------------------------PhysicalProject
--------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_current_addr_sk = ad2.ca_address_sk))otherCondition=()
--------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_cdemo_sk = cd1.cd_demo_sk))otherCondition=()
----------------------------------------------------------PhysicalDistribute
------------------------------------------------------------PhysicalProject
--------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((customer.c_current_hdemo_sk = hd2.hd_demo_sk))otherCondition=()
--------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_hdemo_sk = hd1.hd_demo_sk))otherCondition=()
----------------------------------------------------------------PhysicalProject
------------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number))otherCondition=()
--------------------------------------------------------------------PhysicalProject
----------------------------------------------------------------------PhysicalOlapScan[store_returns]
------------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_sold_date_sk = d1.d_date_sk))otherCondition=()
--------------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = item.i_item_sk))otherCondition=()
----------------------------------------------------------------------PhysicalProject
------------------------------------------------------------------------PhysicalOlapScan[store_sales]
----------------------------------------------------------------------PhysicalDistribute
------------------------------------------------------------------------PhysicalProject
--------------------------------------------------------------------------filter((item.i_current_price <= 58.00) and (item.i_current_price >= 49.00) and i_color IN ('blush', 'lace', 'lawn', 'misty', 'orange', 'pink'))
----------------------------------------------------------------------------PhysicalOlapScan[item]
--------------------------------------------------------------------PhysicalDistribute
----------------------------------------------------------------------PhysicalProject
------------------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_customer_sk = customer.c_customer_sk))otherCondition=()
--------------------------------------------------------------------------PhysicalDistribute
----------------------------------------------------------------------------PhysicalProject
------------------------------------------------------------------------------PhysicalOlapScan[customer]
--------------------------------------------------------------------------PhysicalDistribute
----------------------------------------------------------------------------PhysicalProject
------------------------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_cdemo_sk = cd1.cd_demo_sk))otherCondition=()
--------------------------------------------------------------------------------PhysicalDistribute
----------------------------------------------------------------------------------PhysicalProject
------------------------------------------------------------------------------------PhysicalOlapScan[customer_demographics]
--------------------------------------------------------------------------------PhysicalDistribute
----------------------------------------------------------------------------------PhysicalProject
------------------------------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_sold_date_sk = d1.d_date_sk))otherCondition=()
--------------------------------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = item.i_item_sk))otherCondition=()
----------------------------------------------------------------------------------------PhysicalProject
------------------------------------------------------------------------------------------PhysicalOlapScan[store_sales]
----------------------------------------------------------------------------------------PhysicalDistribute
------------------------------------------------------------------------------------------PhysicalProject
--------------------------------------------------------------------------------------------filter((item.i_current_price <= 58.00) and (item.i_current_price >= 49.00) and i_color IN ('blush', 'lace', 'lawn', 'misty', 'orange', 'pink'))
----------------------------------------------------------------------------------------------PhysicalOlapScan[item]
--------------------------------------------------------------------------------------PhysicalDistribute
----------------------------------------------------------------------------------------PhysicalProject
------------------------------------------------------------------------------------------filter(d_year IN (1999, 2000))
--------------------------------------------------------------------------------------------PhysicalOlapScan[date_dim]
------------------------------------------------------------------------filter(d_year IN (1999, 2000))
--------------------------------------------------------------------------PhysicalOlapScan[date_dim]
----------------------------------------------------------------PhysicalDistribute
------------------------------------------------------------------PhysicalProject
--------------------------------------------------------------------PhysicalOlapScan[household_demographics]
--------------------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((hd1.hd_income_band_sk = ib1.ib_income_band_sk))otherCondition=()
----------------------------------------------------------------------PhysicalDistribute
------------------------------------------------------------------------PhysicalProject
--------------------------------------------------------------------------PhysicalOlapScan[household_demographics]
----------------------------------------------------------------------PhysicalDistribute
------------------------------------------------------------------------PhysicalProject
--------------------------------------------------------------------------PhysicalOlapScan[income_band]
----------------------------------------------------------PhysicalDistribute
------------------------------------------------------------PhysicalProject
--------------------------------------------------------------PhysicalOlapScan[customer_address]
--------------------------------------------------------------PhysicalOlapScan[customer_demographics]
----------------------------------------------------PhysicalDistribute
------------------------------------------------------PhysicalProject
--------------------------------------------------------PhysicalOlapScan[customer_demographics]
------------------------------------------------PhysicalDistribute
--------------------------------------------------PhysicalProject
----------------------------------------------------PhysicalOlapScan[promotion]
--------------------------------------------PhysicalDistribute
--------------------------------------------------------PhysicalOlapScan[customer_address]
----------------------------------------------PhysicalProject
------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((hd1.hd_income_band_sk = ib1.ib_income_band_sk))otherCondition=()
--------------------------------------------------PhysicalDistribute
----------------------------------------------------PhysicalProject
------------------------------------------------------PhysicalOlapScan[household_demographics]
--------------------------------------------------PhysicalDistribute
----------------------------------------------------PhysicalProject
------------------------------------------------------PhysicalOlapScan[income_band]
--------------------------------------PhysicalDistribute
----------------------------------------PhysicalProject
------------------------------------------PhysicalOlapScan[customer_address]
----------------------------------PhysicalDistribute
------------------------------------PhysicalProject
--------------------------------------PhysicalOlapScan[income_band]
------------------------------------------------filter((sale > (2 * refund)))
--------------------------------------------------hashAgg[GLOBAL]
----------------------------------------------------PhysicalDistribute
------------------------------------------------------hashAgg[LOCAL]
--------------------------------------------------------PhysicalProject
----------------------------------------------------------hashJoin[INNER_JOIN] hashCondition=((catalog_sales.cs_item_sk = catalog_returns.cr_item_sk) and (catalog_sales.cs_order_number = catalog_returns.cr_order_number))otherCondition=()
------------------------------------------------------------PhysicalProject
--------------------------------------------------------------PhysicalOlapScan[catalog_sales]
------------------------------------------------------------PhysicalProject
--------------------------------------------------------------PhysicalOlapScan[catalog_returns]
------------------------------PhysicalDistribute
--------------------------------PhysicalProject
----------------------------------PhysicalOlapScan[date_dim]
--------------------------PhysicalDistribute
----------------------------PhysicalProject
------------------------------PhysicalOlapScan[date_dim]
--------------------PhysicalProject
----------------------filter((sale > (2 * refund)))
------------------------hashAgg[GLOBAL]
--------------------------PhysicalDistribute
----------------------------hashAgg[LOCAL]
------------------------------PhysicalProject
--------------------------------hashJoin[INNER_JOIN] hashCondition=((catalog_sales.cs_item_sk = catalog_returns.cr_item_sk) and (catalog_sales.cs_order_number = catalog_returns.cr_order_number))otherCondition=()
----------------------------------PhysicalProject
------------------------------------PhysicalOlapScan[catalog_sales]
----------------------------------PhysicalProject
------------------------------------PhysicalOlapScan[catalog_returns]
------------------------PhysicalDistribute
--------------------------PhysicalProject
----------------------------PhysicalOlapScan[customer_demographics]
--------------------PhysicalDistribute
----------------------PhysicalProject
------------------------PhysicalOlapScan[promotion]
----------------PhysicalDistribute
------------------PhysicalProject
--------------------PhysicalOlapScan[store]
Expand Down
Loading