nozjkoitop opened a new pull request, #16248:
URL: https://github.com/apache/druid/pull/16248

   ### Description
   
   This pull request introduces a configurable `druid.sql.planner.bloat` 
parameter in CalciteRulesManager.
   
   #### Fixed the problem when complicated nested sql queries which where 
working before Druid 29.0.0 (1.21.0 calcite version) are being rejected by 
calcite planner.
   
   With exception:
   `There are not enough rules to produce a node with desired properties: 
convention=DRUID, sort=[]`
   
   Appears that the exceptiom is being thrown, when the root `RelNode` which 
initially is instance of `AbstractConverter` is being treated as 
`ProjectMergeRule`, which counts the result of merge not optimal and reject 
merging, which means that transformation of AbstractConverter [is not 
happening](https://github.com/apache/calcite/blob/75750b78b5ac692caa654f506fc1515d4d3991d6/core/src/main/java/org/apache/calcite/rel/rules/ProjectMergeRule.java#L129,),
 so at the end of the day this `AbstractConverter` instance keeps skipping 
bestCost initialization, because it returns default [infinite 
value](https://github.com/apache/calcite/blob/75750b78b5ac692caa654f506fc1515d4d3991d6/core/src/main/java/org/apache/calcite/plan/volcano/AbstractConverter.java#L75)
  which is being skipped by  
[VolcanoPlanner](https://github.com/apache/calcite/blob/75750b78b5ac692caa654f506fc1515d4d3991d6/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java#L984).
 That's why bestCost to root relNode 
 is never set which is causing 
[exception](https://github.com/apache/calcite/blob/fe0da064dc3081b140e3c84e109aed63f202a4af/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java#L550.)
 
   This issue is probably caused by lots of optimizations in `VolcanoPlanner 
`and `ProjectMergeRule` and looks like as a calcite bug.
   
   
   #### Release note
   Created workaround: configurable `druid.sql.planner.bloat` parameter, which 
should be set on broker `jvm.conf`,  it will adjust the limits of 
`ProjectMergeRule` result cost and could allow running complex queries(default 
value 100, suggested 1000, but it depends on data to be processed). 
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `CalciteRulesManager`
   
   <hr>
   
   This PR has:
   
   - [x] been self-reviewed.
   - [ ] added documentation for new or modified features or behaviors.
   - [x] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [x] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] added integration tests.
   - [x] been tested in a test Druid cluster.


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