Class ImplementDistinctRule


  • @API(EXPERIMENTAL)
    public class ImplementDistinctRule
    extends PlannerRule<LogicalDistinctExpression>
    A rule that implements a distinct expression by adding a RecordQueryUnorderedPrimaryKeyDistinctPlan if necessary. In particular, it will only add that wrapping expression if the underlying plan itself might produce duplicate results.

    This rule is somewhat suspect. In particular, if the inner plan that it matches against does not produce duplicates, this rule will then return that plan. This is fine unless the plan is later modified in such a way that it then can produce duplicates. At the moment, none of the rules modify a RecordQueryPlan once it has been produced, but a future rule that does so may cause errors where plans erroneously produce duplicate records. To address that, the plan is to add a mechanism for enforcing properties (e.g., distinctness or sort order) on the plans produced by the planner. See Issue #653.