gianm commented on a change in pull request #9773:
URL: https://github.com/apache/druid/pull/9773#discussion_r421173321



##########
File path: 
sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidJoinQueryRel.java
##########
@@ -293,23 +293,17 @@ protected RelDataType deriveRowType()
   @Override
   public RelOptCost computeSelfCost(final RelOptPlanner planner, final 
RelMetadataQuery mq)
   {
-    double cost;
-
-    if (computeLeftRequiresSubquery(getSomeDruidChild(left))) {
-      cost = CostEstimates.COST_JOIN_SUBQUERY;
-    } else {
-      cost = partialQuery.estimateCost();
-    }
-
-    if (computeRightRequiresSubquery(getSomeDruidChild(right))) {
-      cost += CostEstimates.COST_JOIN_SUBQUERY;
-    }
-
+    double cost = partialQuery.estimateCost();
     if (joinRel.getCondition().isA(SqlKind.LITERAL) && 
!joinRel.getCondition().isAlwaysFalse()) {
       cost += CostEstimates.COST_JOIN_CROSS;
     }
-
-    return planner.getCostFactory().makeCost(cost, 0, 0);
+    // This is to cancel out the MULTIPLIER_FILTER (value=0.1) from 
partialQuery.estimateCost() to discourage
+    // filter push down if pushing down the filter makes this 
DruidJoinQueryRel not a scan or mapping.
+    // This will leave the filter at the topmost DruidJoinQueryRel (due to the 
order of applying/popping rules).

Review comment:
       After thinking about this for a while, I'm thinking that a less-sketchy 
method would be to remove the rules that push filters past joins. It's similar 
to how #9648 (temporarily) addressed issues related to bad join orderings by 
just nuking the rules that reordered joins. It makes sense since we don't have 
a good way to guide the optimizer at this point.
   
   We'll want to reintroduce these rules when we've made improvements to the 
cost estimators that allow all these rules to operate at their full power.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to