Class CompatibilityLookup<T>

java.lang.Object
org.apache.calcite.schema.lookup.IgnoreCaseLookup<T>
org.apache.calcite.schema.lookup.CompatibilityLookup<T>
Type Parameters:
T - Element type
All Implemented Interfaces:
Lookup<T>

public class CompatibilityLookup<T> extends IgnoreCaseLookup<T>
This class warps a Function and a Supplier into a Lookup interface.

This class can be used to implement the methods Schema.tables() and Schema.subSchemas() of existing schemas.

Existing schema classes are implementing a pair of getTable() and getTableNames() methods. But these schemas should also provide a tables() method. This class can be used to implement this method. See Schema.tables() for an example.

  • Constructor Details

    • CompatibilityLookup

      public CompatibilityLookup(Function<String,@Nullable T> get, Supplier<Set<String>> getNames)
      Constructor to create a Lookup instance using a `Function` and a `Supplier`.
      Parameters:
      get - a function to lookup tables or sub schemas by name
      getNames - a function to list all tables or sub schemas
  • Method Details

    • get

      public @Nullable T get(String name)
      Description copied from class: IgnoreCaseLookup
      Returns a named entity with a given name, or null if not found.
      Specified by:
      get in interface Lookup<T>
      Specified by:
      get in class IgnoreCaseLookup<T>
      Parameters:
      name - Name
      Returns:
      Entity with the specified name, or null when the entity is not found.
    • getNames

      public Set<String> getNames(LikePattern pattern)
      Description copied from interface: Lookup
      Returns the names of the entities in matching pattern. The search is always case sensitive. This is caused by the fact that DatabaseMetaData.getTables(...) doesn't support case insensitive lookups.
      Specified by:
      getNames in interface Lookup<T>
      Specified by:
      getNames in class IgnoreCaseLookup<T>
      Returns:
      The names of all entities matching the pattern.