nozjkoitop commented on code in PR #16248:
URL: https://github.com/apache/druid/pull/16248#discussion_r1574791915


##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/CalciteRulesManager.java:
##########
@@ -95,12 +100,16 @@ public class CalciteRulesManager
    * and {@link CoreRules#FILTER_INTO_JOIN}, which are part of {@link 
#FANCY_JOIN_RULES}.
    * 4) {@link CoreRules#PROJECT_FILTER_TRANSPOSE} because PartialDruidQuery 
would like to have the Project on top of the Filter -
    * this rule could create a lot of non-useful plans.
+   *
+   * {@link CoreRules#PROJECT_MERGE} includes configurable bloat parameter, as 
a workaround for Calcite exception
+   * (there are not enough rules to produce a node with desired properties) 
thrown while running complex sql-queries with
+   * big amount of subqueries. `druid.sql.planner.bloat` should be set in 
broker's `jvm.config` file.
    */
   private static final List<RelOptRule> BASE_RULES =
       ImmutableList.of(
           CoreRules.AGGREGATE_STAR_TABLE,
           CoreRules.AGGREGATE_PROJECT_STAR_TABLE,
-          CoreRules.PROJECT_MERGE,
+          ProjectMergeRule.Config.DEFAULT.withBloat(BLOAT).toRule(),

Review Comment:
   Honestly, these are calcite internals, and all we get on the druid side is 
[RelOptPlanner.CannotPlanException](https://github.com/apache/calcite/blob/fe0da064dc3081b140e3c84e109aed63f202a4af/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java#L718),
 which I believe could be thrown by tons of reasons. We can add the suggestion 
to try to set this context parameter at 
[QueryHandler](https://github.com/apache/druid/blob/173a206829e5fff7580fae068928a79f10726124/sql/src/main/java/org/apache/druid/sql/calcite/planner/QueryHandler.java#L676),
 but IMO it's a real shot in the dark there.



-- 
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.

To unsubscribe, e-mail: [email protected]

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