[ 
https://issues.apache.org/jira/browse/CALCITE-6998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949655#comment-17949655
 ] 

Zhen Chen commented on CALCITE-6998:
------------------------------------

[~julianhyde] Thank you for your patience and guidance. I have updated the 
description of the problem and the solution.

> The command !set planner-rules does not support rules with multiple Config
> --------------------------------------------------------------------------
>
>                 Key: CALCITE-6998
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6998
>             Project: Calcite
>          Issue Type: New Feature
>            Reporter: Zhen Chen
>            Assignee: Zhen Chen
>            Priority: Major
>              Labels: pull-request-available
>
> Problem Description:
> For example, ExpandDisjunctionForJoinInputsRule contains two Configs, FILTER 
> and JOIN.
> {code:java}
> @Value.Immutable(singleton = false)
> public interface Config extends RelRule.Config {
>   Config FILTER = ImmutableExpandDisjunctionForJoinInputsRule.Config.builder()
>     .withDescription("ExpandDisjunctionForJoinInputsRule(Filter)")
>     .withMatchHandler(ExpandDisjunctionForJoinInputsRule::matchFilter)
>     .build()
>     .withOperandSupplier(b0 ->
>         b0.operand(Filter.class).oneInput(b1 ->
>             b1.operand(Join.class).anyInputs()));  Config JOIN = 
> ImmutableExpandDisjunctionForJoinInputsRule.Config.builder()
>     .withDescription("ExpandDisjunctionForJoinInputsRule(Join)")
>     .withMatchHandler(ExpandDisjunctionForJoinInputsRule::matchJoin)
>     .build()
>     .withOperandSupplier(b -> b.operand(Join.class).anyInputs());  ......
> } {code}
> When using reflection to load rules in CoreRules, the following rules cannot 
> be instantiated correctly.
> {code:java}
> public static final ExpandDisjunctionForJoinInputsRule 
> EXPAND_FILTER_DISJUNCTION_LOCAL 
> = ExpandDisjunctionForJoinInputsRule.Config.FILTER.toRule();
> ​
> public static final ExpandDisjunctionForJoinInputsRule 
> EXPAND_JOIN_DISJUNCTION_LOCAL 
> = ExpandDisjunctionForJoinInputsRule.Config.JOIN.toRule();{code}
> If both rules are loaded simultaneously, they both end up using 
> ExpandDisjunctionForJoinInputsRule.Config.FILTER.toRule().
> Solution:
> Add an annotation {{@RuleConfig(value="XXX")}} to each rule in CoreRules, 
> where the {{value}} identifies the name of the Config used by the rule. For 
> example:
> {code:java}
> @RuleConfig(value = "JOIN")
> public static final ExpandDisjunctionForJoinInputsRule 
> EXPAND_JOIN_DISJUNCTION_LOCAL =
>     ExpandDisjunctionForJoinInputsRule.Config.JOIN.toRule(); {code}
> This indicates that the rule uses the {{JOIN}} Config.
> If a rule has only one Config named {{{}DEFAULT{}}}, the annotation is not 
> required.
> This way, during reflection, the correct rule instance can be obtained based 
> on the {{@RuleConfig}} annotation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to