Interface RelTrait

All Known Subinterfaces:
Convention, RelCollation, RelDistribution, RelMultipleTrait
All Known Implementing Classes:
BindableConvention, Convention.Impl, EnumerableConvention, InterpretableConvention, JdbcConvention, RelCollationImpl

public interface RelTrait
RelTrait represents the manifestation of a relational expression trait within a trait definition. For example, a CallingConvention.JAVA is a trait of the ConventionTraitDef trait definition.

Note about equals() and hashCode()

If all instances of RelTrait for a particular RelTraitDef are defined in an enum and no new RelTraits can be introduced at runtime, you need not override hashCode() and equals(Object). If, however, new RelTrait instances are generated at runtime (e.g. based on state external to the planner), you must implement hashCode() and equals(Object) for proper canonization of your RelTrait objects.

  • Method Details

    • getTraitDef

      RelTraitDef getTraitDef()
      Returns the RelTraitDef that defines this RelTrait.
      the RelTraitDef that defines this RelTrait
    • hashCode

      int hashCode()
      hashCode in class Object
    • equals

      boolean equals(@Nullable Object o)
      equals in class Object
    • satisfies

      boolean satisfies(RelTrait trait)
      Returns whether this trait satisfies a given trait.

      A trait satisfies another if it is the same or stricter. For example, ORDER BY x, y satisfies ORDER BY x.

      A trait's satisfies relation must be a partial order (reflexive, anti-symmetric, transitive). Many traits cannot be "loosened"; their satisfies is an equivalence relation, where only X satisfies X.

      If a trait has multiple values (see RelCompositeTrait) a collection (T0, T1, ...) satisfies T if any Ti satisfies T.

      trait - Given trait
      Whether this trait subsumes a given trait
    • toString

      String toString()
      Returns a succinct name for this trait. The planner may use this String to describe the trait.
      toString in class Object
    • register

      void register(RelOptPlanner planner)
      Registers a trait instance with the planner.

      This is an opportunity to add rules that relate to that trait. However, typical implementations will do nothing.

      planner - Planner
    • apply

      default <T extends RelTrait> T apply(Mappings.TargetMapping mapping)
      Applies a mapping to this trait.

      Some traits may be changed if the columns order is changed by a mapping of the Project operator.

      For example, if relation SELECT a, b ORDER BY a, b is sorted by columns [0, 1], then the project SELECT b, a over this relation will be sorted by columns [1, 0]. In the same time project SELECT b will not be sorted at all because it doesn't contain the collation prefix and this method will return an empty collation.

      Other traits are independent from the columns remapping. For example Convention or RelDistributions.SINGLETON.

      mapping - Mapping
      trait with mapping applied
    • isDefault

      default boolean isDefault()
      Returns whether this trait is the default trait value.