Class RelMetadataQueryBase

java.lang.Object
org.apache.calcite.rel.metadata.RelMetadataQueryBase
Direct Known Subclasses:
RelMetadataQuery

public class RelMetadataQueryBase extends Object
Base class for the RelMetadataQuery that uses the metadata handler class generated by the Janino.

To add a new implementation to this interface, follow these steps:

  1. Extends RelMetadataQuery (name it MyRelMetadataQuery for example) to reuse the Calcite builtin metadata query interfaces. In this class, define all the extended Handlers for your metadata and implement the metadata query interfaces.
  2. Write your customized provider class RelMdXyz. Follow the pattern from an existing class such as RelMdColumnOrigins, overloading on all of the logical relational expressions to which the query applies.
  3. Add a SOURCE static member to each of your provider class, similar to RelMdColumnOrigins.SOURCE.
  4. Extends DefaultRelMetadataProvider (name it MyRelMetadataProvider for example) and supplement the "SOURCE"s into the builtin list (This is not required, use ChainedRelMetadataProvider to chain your customized "SOURCE"s with default ones also works).
  5. Set MyRelMetadataProvider into the cluster instance.
  6. Use RelOptCluster.setMetadataQuerySupplier(Supplier) to set the metadata query Supplier into the cluster instance. This Supplier should return a fresh new instance.
  7. Use the cluster instance to create SqlToRelConverter.
  8. Query your metadata within RelOptRuleCall with the interfaces you defined in MyRelMetadataQuery.
  • Field Details

  • Constructor Details

  • Method Details

    • initialHandler

      @Deprecated protected static <H> H initialHandler(Class<H> handlerClass)
      Deprecated.
    • revise

      @Deprecated protected <M extends Metadata, H extends MetadataHandler<M>> H revise(Class<? extends RelNode> class_, MetadataDef<M> def)
      Deprecated.
      Re-generates the handler for a given kind of metadata, adding support for class_ if it is not already present.
    • revise

      protected <H extends MetadataHandler<?>> H revise(Class<H> def)
      Re-generates the handler for a given kind of metadata, adding support for class_ if it is not already present.
    • handler

      protected <MH extends MetadataHandler<?>> MH handler(Class<MH> handlerClass)
      Provide a handler for the requested metadata class.
      Type Parameters:
      MH - The metadata type the handler relates to.
      Parameters:
      handlerClass - The handler interface expected
      Returns:
      The handler implementation.
    • clearCache

      public boolean clearCache(RelNode rel)
      Removes cached metadata values for specified RelNode.
      Parameters:
      rel - RelNode whose cached metadata should be removed
      Returns:
      true if cache for the provided RelNode was not empty