Class RelMetadataQuery

java.lang.Object
org.apache.calcite.rel.metadata.RelMetadataQueryBase
org.apache.calcite.rel.metadata.RelMetadataQuery

public class RelMetadataQuery extends RelMetadataQueryBase
RelMetadataQuery provides a strongly-typed facade on top of RelMetadataProvider for the set of relational expression metadata queries defined as standard within Calcite. The Javadoc on these methods serves as their primary specification.

To add a new standard query Xyz to this interface, follow these steps:

  1. Add a static method getXyz specification to this class.
  2. Add unit tests to org.apache.calcite.test.RelMetadataTest.
  3. Write a new provider class RelMdXyz in this package. Follow the pattern from an existing class such as RelMdColumnOrigins, overloading on all of the logical relational expressions to which the query applies.
  4. Add a SOURCE static member, similar to RelMdColumnOrigins.SOURCE.
  5. Register the SOURCE object in DefaultRelMetadataProvider.
  6. Get unit tests working.

Because relational expression metadata is extensible, extension projects can define similar facades in order to specify access to custom metadata. Please do not add queries here (nor on RelNode) which lack meaning outside of your extension.

Besides adding new metadata queries, extension projects may need to add custom providers for the standard queries in order to handle additional relational expressions (either logical or physical). In either case, the process is the same: write a reflective provider and chain it on to an instance of DefaultRelMetadataProvider, pre-pending it to the default providers. Then supply that instance to the planner via the appropriate plugin mechanism.