Package org.apache.calcite.rel.metadata
Class RelMetadataQueryBase
java.lang.Object
org.apache.calcite.rel.metadata.RelMetadataQueryBase
- Direct Known Subclasses:
RelMetadataQuery
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:
- 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. - Write your customized provider class
RelMdXyz. Follow the pattern from an existing class such asRelMdColumnOrigins, overloading on all of the logical relational expressions to which the query applies. - Add a
SOURCEstatic member to each of your provider class, similar toRelMdColumnOrigins.SOURCE. - Extends
DefaultRelMetadataProvider(name it MyRelMetadataProvider for example) and supplement the "SOURCE"s into the builtin list (This is not required, useChainedRelMetadataProviderto chain your customized "SOURCE"s with default ones also works). - Set
MyRelMetadataProviderinto the cluster instance. - Use
RelOptCluster.setMetadataQuerySupplier(Supplier)to set the metadata querySupplierinto the cluster instance. ThisSuppliershould return a fresh new instance. - Use the cluster instance to create
SqlToRelConverter. - Query your metadata within
RelOptRuleCallwith the interfaces you defined inMyRelMetadataQuery.
-
Field Summary
FieldsModifier and TypeFieldDescriptionSet of active metadata queries, and cache of previous results.final @Nullable JaninoRelMetadataProviderDeprecated.static final ThreadLocal<@Nullable JaninoRelMetadataProvider> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRelMetadataQueryBase(@Nullable JaninoRelMetadataProvider metadataProvider) Deprecated.protectedRelMetadataQueryBase(@Nullable MetadataHandlerProvider provider) -
Method Summary
Modifier and TypeMethodDescriptionbooleanclearCache(RelNode rel) Removes cached metadata values for specified RelNode.protected <MH extends MetadataHandler<?>>
MHProvide a handler for the requested metadata class.protected static <H> HinitialHandler(Class<H> handlerClass) Deprecated.protected <M extends Metadata,H extends MetadataHandler<M>>
Hrevise(Class<? extends RelNode> class_, MetadataDef<M> def) Deprecated.protected <H extends MetadataHandler<?>>
HRe-generates the handler for a given kind of metadata, adding support forclass_if it is not already present.
-
Field Details
-
map
Set of active metadata queries, and cache of previous results. -
metadataProvider
Deprecated. -
THREAD_PROVIDERS
-
-
Constructor Details
-
RelMetadataQueryBase
Deprecated. -
RelMetadataQueryBase
-
-
Method Details
-
initialHandler
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 forclass_if it is not already present. -
revise
Re-generates the handler for a given kind of metadata, adding support forclass_if it is not already present. -
handler
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
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
-