@@ -477,9 +477,9 @@ bool isIndexColocated(
477477 const IndexInfo& info,
478478 const ExprVector& lookupValues,
479479 const RelationOpPtr& input) {
480- const auto & distribution = info.index ->distribution ;
480+ const auto & desired = info.index ->distribution ;
481481 if (const auto needsShuffle =
482- input->distribution ().maybeNeedsShuffle (distribution )) {
482+ input->distribution ().maybeNeedsShuffle (desired )) {
483483 return !*needsShuffle;
484484 }
485485 // TODO: Future partition type should be accounted.
@@ -490,8 +490,7 @@ bool isIndexColocated(
490490 for (size_t i = 0 ; i < input->distribution ().partition .size (); ++i) {
491491 auto nthKey = position (lookupValues, *input->distribution ().partition [i]);
492492 if (nthKey == kNotFound ||
493- info.schemaColumn (info.lookupKeys [nthKey]) !=
494- distribution.partition [i]) {
493+ info.schemaColumn (info.lookupKeys [nthKey]) != desired.partition [i]) {
495494 return false ;
496495 }
497496 }
@@ -600,7 +599,7 @@ PlanObjectSet availableColumns(BaseTableCP baseTable, ColumnGroupCP index) {
600599}
601600
602601bool isBroadcastableSize (PlanP build, PlanState& /* state*/ ) {
603- return build->cost .fanout < 100'000 ;
602+ return build->cost .resultCardinality () < 100'000 ;
604603}
605604
606605// The 'other' side gets shuffled to align with 'input'. If 'input' is not
@@ -1303,7 +1302,7 @@ void Optimization::addJoin(
13031302 if (toTry.size () == 2 && candidate.tables .size () == 1 ) {
13041303 VELOX_DCHECK (!options_.syntacticJoinOrder );
13051304 if (toTry[0 ].isWorse (toTry[1 ])) {
1306- std::swap ( toTry[0 ], toTry[1 ]);
1305+ toTry[0 ] = std::move ( toTry[1 ]);
13071306 toTry.pop_back ();
13081307 } else if (toTry[1 ].isWorse (toTry[0 ])) {
13091308 toTry.pop_back ();
@@ -1548,9 +1547,11 @@ PlanP unionPlan(
15481547 for (auto i = 1 ; i < states.size (); ++i) {
15491548 const auto & otherCost = states[i].cost ;
15501549 fullyImported.intersect (inputPlans[i]->fullyImported );
1551- firstState.cost .add (otherCost);
1552- // The input cardinality is not additive, the fanout and other metrics are.
1553- firstState.cost .inputCardinality -= otherCost.inputCardinality ;
1550+ // The input cardinality is not additive.
1551+ firstState.cost .setupCost += otherCost.setupCost ;
1552+ firstState.cost .unitCost += otherCost.unitCost ;
1553+ firstState.cost .totalBytes += otherCost.totalBytes ;
1554+ firstState.cost .transferBytes += otherCost.transferBytes ;
15541555 }
15551556 if (distinct) {
15561557 firstState.addCost (*distinct);
0 commit comments