Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Jul 30, 2024
1 parent 1b17f99 commit e6a185d
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public Rule build() {
break;
}
}
if (commonChild == null) {
if (commonChild == null || commonChild.isEmpty()) {
return null;
}

Expand Down Expand Up @@ -181,8 +181,8 @@ private Plan constructNewJoinUnion(
commonChild, joinSlotToProject, constantAlias, missSlotMap, originChildSlotToUnion);

// 2. construct join union
LogicalJoin<?, ?> originalJoin = commonChild.iterator().next().first;
Plan newChild = commonChild.iterator().next().second;
LogicalJoin<?, ?> originalJoin = commonChild.get(0).first;
Plan newChild = commonChild.get(0).second;
Plan newJoin = constructNewJoin(originalJoin, newUnion, newChild);

// 3. map the output to origin output
Expand Down Expand Up @@ -379,7 +379,8 @@ private boolean tryMapJoinSlotToUnion(LogicalUnion union, List<Pair<LogicalJoin<
}
} else {
for (int slotIdx = 0; slotIdx < union.getRegularChildOutput(i).size(); slotIdx++) {
originChildSlotToUnion.put(child.getOutput().get(slotIdx), union.getOutput().get(slotIdx));
originChildSlotToUnion.put(union.getRegularChildOutput(i).get(slotIdx),
union.getOutput().get(slotIdx));
}
}

Expand All @@ -403,8 +404,9 @@ private boolean tryMapJoinSlotToUnion(LogicalUnion union, List<Pair<LogicalJoin<
}
}
} else {
for (Slot slot : child.getOutput()) {
joinSlotToProject.put(slot, slot);
for (int slotIdx = 0; slotIdx < union.getRegularChildOutput(i).size(); slotIdx++) {
joinSlotToProject.put(union.getRegularChildOutput(i).get(slotIdx),
union.getRegularChildOutput(i).get(slotIdx));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public OlapTable getTable() {

@Override
public String toString() {
return Utils.toSqlString("LogicalOlapScan",
return Utils.toSqlString("LogicalOlapScan[" + id.asInt() + "]",
"qualified", qualifiedName(),
"indexName", getSelectedMaterializedIndexName().orElse("<index_not_selected>"),
"selectedIndexId", selectedIndexId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !ds_shape_23_2 --
PhysicalCteAnchor ( cteId=CTEId#0 )
--PhysicalCteProducer ( cteId=CTEId#0 )
----PhysicalProject
------filter((cnt > 4))
--------hashAgg[GLOBAL]
----------PhysicalDistribute[DistributionSpecHash]
------------hashAgg[LOCAL]
--------------PhysicalProject
----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ss_item_sk]
------------------PhysicalProject
--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk]
----------------------PhysicalProject
------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1
----------------------PhysicalProject
------------------------filter(d_year IN (2000, 2001, 2002, 2003))
--------------------------PhysicalOlapScan[date_dim]
------------------PhysicalProject
--------------------PhysicalOlapScan[item]
--PhysicalCteAnchor ( cteId=CTEId#2 )
----PhysicalCteProducer ( cteId=CTEId#2 )
------PhysicalProject
--------NestedLoopJoin[INNER_JOIN](cast(ssales as DOUBLE) > cast((0.9500 * tpcds_cmax) as DOUBLE))
----------PhysicalProject
------------hashAgg[GLOBAL]
--------------PhysicalDistribute[DistributionSpecHash]
----------------hashAgg[LOCAL]
------------------PhysicalProject
--------------------filter(( not ss_customer_sk IS NULL))
----------------------PhysicalOlapScan[store_sales]
----------PhysicalProject
------------hashAgg[GLOBAL]
--------------PhysicalDistribute[DistributionSpecGather]
----------------hashAgg[LOCAL]
------------------PhysicalProject
--------------------hashAgg[GLOBAL]
----------------------PhysicalDistribute[DistributionSpecHash]
------------------------hashAgg[LOCAL]
--------------------------PhysicalProject
----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk]
------------------------------PhysicalProject
--------------------------------filter(( not ss_customer_sk IS NULL))
----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2
------------------------------PhysicalProject
--------------------------------filter(d_year IN (2000, 2001, 2002, 2003))
----------------------------------PhysicalOlapScan[date_dim]
----PhysicalResultSink
------PhysicalTopN[MERGE_SORT]
--------PhysicalDistribute[DistributionSpecGather]
----------PhysicalTopN[LOCAL_SORT]
------------PhysicalProject
--------------hashJoin[INNER_JOIN shuffle] hashCondition=((cs_bill_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 cs_bill_customer_sk->[c_customer_sk]
----------------PhysicalProject
------------------PhysicalOlapScan[customer] apply RFs: RF5
----------------PhysicalProject
------------------PhysicalUnion
--------------------hashAgg[GLOBAL]
----------------------PhysicalDistribute[DistributionSpecHash]
------------------------hashAgg[LOCAL]
--------------------------PhysicalProject
----------------------------hashJoin[LEFT_SEMI_JOIN shuffle] hashCondition=((catalog_sales.cs_item_sk = frequent_ss_items.item_sk)) otherCondition=()
------------------------------hashJoin[LEFT_SEMI_JOIN shuffle] hashCondition=((catalog_sales.cs_bill_customer_sk = best_ss_customer.c_customer_sk)) otherCondition=()
--------------------------------PhysicalProject
----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[cs_sold_date_sk]
------------------------------------PhysicalProject
--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF3
------------------------------------PhysicalProject
--------------------------------------filter((date_dim.d_moy = 5) and (date_dim.d_year = 2000))
----------------------------------------PhysicalOlapScan[date_dim]
--------------------------------PhysicalCteConsumer ( cteId=CTEId#2 )
------------------------------PhysicalCteConsumer ( cteId=CTEId#0 )
--------------------hashAgg[GLOBAL]
----------------------PhysicalDistribute[DistributionSpecHash]
------------------------hashAgg[LOCAL]
--------------------------PhysicalProject
----------------------------hashJoin[LEFT_SEMI_JOIN shuffle] hashCondition=((web_sales.ws_item_sk = frequent_ss_items.item_sk)) otherCondition=()
------------------------------hashJoin[LEFT_SEMI_JOIN shuffle] hashCondition=((web_sales.ws_bill_customer_sk = best_ss_customer.c_customer_sk)) otherCondition=()
--------------------------------PhysicalProject
----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ws_sold_date_sk]
------------------------------------PhysicalProject
--------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF4
------------------------------------PhysicalProject
--------------------------------------filter((date_dim.d_moy = 5) and (date_dim.d_year = 2000))
----------------------------------------PhysicalOlapScan[date_dim]
--------------------------------PhysicalCteConsumer ( cteId=CTEId#2 )
------------------------------PhysicalCteConsumer ( cteId=CTEId#0 )

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

suite("query23_2") {
String db = context.config.getDbNameByFile(new File(context.file.parent))
multi_sql """
use ${db};
set enable_nereids_planner=true;
set enable_nereids_distribute_planner=false;
set enable_fallback_to_original_planner=false;
set exec_mem_limit=21G;
set be_number_for_test=3;
set enable_runtime_filter_prune=false;
set parallel_pipeline_task_num=8;
set forbid_unknown_col_stats=false;
set enable_stats=true;
set runtime_filter_type=8;
set broadcast_row_count_limit = 30000000;
set enable_nereids_timeout = false;
set enable_pipeline_engine = true;
set disable_nereids_rules='PRUNE_EMPTY_PARTITION';
set push_topn_to_agg = true;
set topn_opt_limit_threshold=1024;
"""

def ds = """
with frequent_ss_items as
(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt
from store_sales
,date_dim
,item
where ss_sold_date_sk = d_date_sk
and ss_item_sk = i_item_sk
and d_year in (2000,2000 + 1,2000 + 2,2000 + 3)
group by substr(i_item_desc,1,30),i_item_sk,d_date
having count(*) >4),
max_store_sales as
(select max(csales) tpcds_cmax
from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales
from store_sales
,customer
,date_dim
where ss_customer_sk = c_customer_sk
and ss_sold_date_sk = d_date_sk
and d_year in (2000,2000+1,2000+2,2000+3)
group by c_customer_sk) t),
best_ss_customer as
(select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales
from store_sales
,customer
where ss_customer_sk = c_customer_sk
group by c_customer_sk
having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select
*
from max_store_sales))
select c_last_name,c_first_name,sales
from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales
from catalog_sales
,customer
,date_dim
where d_year = 2000
and d_moy = 5
and cs_sold_date_sk = d_date_sk
and cs_item_sk in (select item_sk from frequent_ss_items)
and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer)
and cs_bill_customer_sk = c_customer_sk
group by c_last_name,c_first_name
union all
select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales
from web_sales
,customer
,date_dim
where d_year = 2000
and d_moy = 5
and ws_sold_date_sk = d_date_sk
and ws_item_sk in (select item_sk from frequent_ss_items)
and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)
and ws_bill_customer_sk = c_customer_sk
group by c_last_name,c_first_name) t2
order by c_last_name,c_first_name,sales
limit 100;"""
qt_ds_shape_23_2 """
explain shape plan
${ds}
"""
}

0 comments on commit e6a185d

Please sign in to comment.