Thanks a lot for the quick response, Atri.
But, I'm still not sure what to do when I use Frameworks.newConfigBuilder().
The following code shows where I am and I don't know what to do next
to optimize the tree based on the costs I want to override.
(computeSelfCost is defined in RelNode under root, but it's already
instantiated so there is no way to override it. So, I think I need to
predefine the costs somewhere.)
/* code start */
FrameworkConfig calciteFrameworkConfig = Frameworks.newConfigBuilder()
.parserConfig(SqlParser.configBuilder()
.setLex(Lex.MYSQL)
.build())
.defaultSchema(schema)
.traitDefs(traitDefs)
.context(Contexts.EMPTY_CONTEXT)
.ruleSets(RuleSets.ofList())
.costFactory(null)
.typeSystem(RelDataTypeSystem.DEFAULT)
.build();
planner = Frameworks.getPlanner(calciteFrameworkConfig);
sqlNode = planner.parse(query);
SqlNode validatedSqlNode = planner.validate(sqlNode);
RelRoot root = planner.rel(validatedSqlNode)
/* code end */
Thanks,
Hiro
On Sun, Sep 11, 2016 at 9:52 PM, Atri Sharma <[email protected]> wrote:
> Apologies,that is computeSelfCost, not computeSelf.
>
> On Sun, Sep 11, 2016 at 6:21 PM, Atri Sharma <[email protected]> wrote:
>
>> If you are looking to change the costing model for a specific planner
>> node, you need to change the costing function for it (for an example, look
>> into a node's computeSelf method).
>>
>> Regards,
>>
>> Atri
>>
>> On 11 Sep 2016 5:57 p.m., "Hiroyuki Yamada" <[email protected]> wrote:
>>
>>> Hello,
>>>
>>> I'm currently trying to use Calcite as a query parser and an optimizer
>>> for my my own database engine
>>> and I'm wondering how I can override the costs in the cost-based
>>> optimizer.
>>>
>>> I've found a good article about Calcite below and it's very helpful,
>>> but it's basically about how to use the parser.
>>> <https://medium.com/@mpathirage/query-planning-with-apache-c
>>> alcite-part-1-fe957b011c36#.ph89c2bvo>
>>>
>>> Would anyone know where I can find good examples or good tutorials
>>> to know more about how to use/override the cost-based optimizer ?
>>> I've read the Calcite tutorials and online documents,
>>> but they are not very helpful from that perspective as far as I've
>>> checked.
>>>
>>> Best regards,
>>> Hiro
>>>
>>
>
>
> --
> Regards,
>
> Atri
> *l'apprenant*