You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ruben Q L (Jira)" <ji...@apache.org> on 2020/08/11 12:52:00 UTC
[jira] [Commented] (CALCITE-3923) Refactor how planner rules are
parameterized
[ https://issues.apache.org/jira/browse/CALCITE-3923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17175537#comment-17175537 ]
Ruben Q L commented on CALCITE-3923:
------------------------------------
[~julianhyde], I have a small follow-up question about this change. I am trying to implement my own version of EnumerableCalcRule, with a special predicate. My code looks like:
{code:java}
private static final Predicate<LogicalCalc> MY_PREDICATE = ...;
private static final RelOptRule MY_ENUMERABLE_CALC_RULE = EnumerableRules.ENUMERABLE_CALC_RULE.config
.withConversion(LogicalCalc.class, MY_PREDICATE, Convention.NONE, EnumerableConvention.INSTANCE, "MyEnumerableCalcRule")
.toRule();
{code}
However, I get a compilation error on EnumerableRules.ENUMERABLE_CALC_RULE.config: {{Cannot access 'config' in 'com.onwbp.org.apache.calcite.plan.RelRule'}}. My assumption is that this error comes from the fact that EnumerableCalcRule (and in fact several Enumerable*Rules) is package private (if I try something similar with a public rule, e.g. FilterIntoJoinRule via CoreRules.FILTER_INTO_JOIN), 'config' is accessible.
Is my analysis correct? Is this the proper way to achieve my goal or am I doing something wrong in my code?
> Refactor how planner rules are parameterized
> --------------------------------------------
>
> Key: CALCITE-3923
> URL: https://issues.apache.org/jira/browse/CALCITE-3923
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: Julian Hyde
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.25.0
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> People often want different variants of planner rules. An example is {{FilterJoinRule}}, which has a 'boolean smart’ parameter, a predicate (which returns whether to pull up filter conditions), operands (which determine the precise sub-classes of {{RelNode}} that the rule should match) and a {{RelBuilderFactory}} (which controls the type of {{RelNode}} created by this rule).
> Suppose you have an instance of {{FilterJoinRule}} and you want to change {{smart}} from true to false. The {{smart}} parameter is immutable (good!) but you can’t easily create a clone of the rule because you don’t know the values of the other parameters. Your instance might even be (unbeknownst to you) a sub-class with extra parameters and a private constructor.
> So, my proposal is to put all of the config information of a {{RelOptRule}} into a single {{config}} parameter that contains all relevant properties. Each sub-class of {{RelOptRule}} would have one constructor with just a ‘config’ parameter. Each config knows which sub-class of {{RelOptRule}} to create. Therefore it is easy to copy a config, change one or more properties, and create a new rule instance.
> Adding a property to a rule’s config does not require us to add or deprecate any constructors.
> The operands are part of the config, so if you have a rule that matches a {{EnumerableFilter}} on an {{EnumerableJoin}} and you want to make it match an {{EnumerableFilter}} on an {{EnumerableNestedLoopJoin}}, you can easily create one with one changed operand.
> The config is immutable and self-describing, so we can use it to automatically generate a unique description for each rule instance.
> (See the email thread [[DISCUSS] Refactor how planner rules are parameterized|https://lists.apache.org/thread.html/rfdf6f9b7821988bdd92b0377e3d293443a6376f4773c4c658c891cf9%40%3Cdev.calcite.apache.org%3E].)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)