Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-828

Use RelBuilder in rules rather than type-specific RelNode factories

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.5.0
    • None
    • None

    Description

      Many planner rules create filters, projects, joins, ... and over the years people have made them generic, so they can create different particular sub-classes of RelNodes (say DrillFilter or HiveProject) by adding factories (interfaces defined in RelFactories).

      But then people extend a rule, so that a rule that used to only create projects now might sometimes create a filter. They now need to add an extra parameter to the instance of the rule, which is painful. Also, rules may call into utility methods such as RelOptUtil.pushDownJoinConditions (see CALCITE-826), which have similar problems.

      The solution is to get rid of factories in public interfaces and instead pass around a RelBuilder. A particular instance of RelBuilder has a factory inside it for each type of RelNode. In general a particular client of Calcite (e.g. Hive) will be able to use the same RelBuilder throughout a query.

      Rules are static, so a rule instance cannot contain a RelBuilder, only a ProtoRelBuilder, which can create a RelBuilder given a RelOptCluster and RelOptSchema.

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              julianhyde Julian Hyde
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: