0

I'm learning about Calcite, but got confused by the ConverterRule and RelOptRule.

I've already got that RelOptRule is the rule to transform an expression to another, and RelOptRule is used by RelOptPlanner.

But I've seen that in ConverterRule's java doc

/**
 * Abstract base class for a rule which converts from one calling convention to
 * another without changing semantics.
 */

What's the difference between ConverterRule and RelOptRule? And how should I use them?

lulijun
  • 415
  • 3
  • 22

1 Answers1

3

ConverterRule is a subclass of the RelOptRule class. Both of these are rules used by the planner to transform relational algebra expressions. A ConverterRule does what the Javadoc you cited states, it converts between calling conventions. This is used for example to allow logical expressions to actually be executed by assigning a particular calling convention, which indicates what system will actually execute the query.

Rules can do many other things besides convert conventions. For example, a rule may decide to exchange the order of Filter and a Project nodes. Really all a rule does is match a subtree of a relational algebra expression and replace it with a different subtree.

Michael Mior
  • 28,107
  • 9
  • 89
  • 113