a34729t opened a new pull request, #20265:
URL: https://github.com/apache/pinot/pull/20265

   Per [issue #20264](https://github.com/apache/pinot/issues/20264), I would 
like to improve the plugin interface for query optimizers to support cost-based 
optimizers. I have an entire CBO implementation, but it is woefully out of date 
due to my employer's artifactory policies. So, a plugin approach seems more 
practical. But this requires a few changes.
   
   ------
   
   ## 2 New Interfaces
   
   This PR adds two new interfaces in `pinot-query-planner-spi` which already 
depends on Calcite (so we don't drag Calcite into the `pinot-spi` 
unnecessarily).
   
   **1. QueryOptimizerProvider**
   
   This is the entry point; a plugin ships one implementation, discovered at 
broker startup via `ServiceLoader` and `PluginManager` (similar to 
`RuleSetCustomizer`), and registered under its name.
    
    Methods:
     - `getName()`: Value a user puts in the `queryOptimizer` query option to 
select this optimizer (e.g. "cbo"). When not set defaults to HEP.
    - `getMetadataProviders()`: Statistics metadata providers the optimizer 
needs. They are at provider-level (created once) rather than on the per-query 
cost model because Calcite's `JaninoRelMetadataProvider` caches generated 
handlers by provider identity.
    - `createCostModelProvider()`: Builds a new per-query `CostModelProvider` 
(avoids racing `configure()` across concurrent queries)
    - `createPlanner(costModelProvider, context, traitDefs)`: Builds 
`RelOptPlanner` for one query; replacing HEP for logical phase.
   
   **2. CostModelProvider**
   
   Per-query cost model methods:
   
    - `getCostFactory()`: Calcite cost factory the plugin's planner uses.
    - `configure(Map<String, String> queryOptions)`: Receives the query's 
options. We do not define a rigid statistics schema; the plugin has to handle 
this. A future ZK-backed statistics source can plug in here, presumably.
    
    ## E2E Test
    
    The `CostBasedOptimizerPluginTest` is an attempt at validating the whole 
interface. It builds a `QueryEnvironment` with a `NoopOptimizerProvider` and 
then runs:
   
    ```sql
      SET queryOptimizer='noop'; SELECT * FROM a
    ```
   
   through the `planQuery` path to exercise the whole pipeline. The plugin 
returns a `VolcanoPlanner` subclass  that does the `Convention.NONE` to 
`NoopConvention` to `Convention.NONE` round-trip.


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