Interface RelNode

    • Method Detail

      • getChildExps

        @Deprecated
        java.util.List<RexNode> getChildExps()
        Deprecated.
        use #accept(org.apache.calcite.rex.RexShuttle)
        Returns a list of this relational expression's child expressions. (These are scalar expressions, and so do not include the relational inputs that are returned by getInputs().

        The caller should treat the list as unmodifiable; typical implementations will return an immutable list. If there are no child expressions, returns an empty list, not null.

        Returns:
        List of this relational expression's child expressions
        See Also:
        accept(org.apache.calcite.rex.RexShuttle)
      • getConvention

        Convention getConvention()
        Return the CallingConvention trait from this RelNode's trait set.
        Returns:
        this RelNode's CallingConvention
      • getCorrelVariable

        java.lang.String getCorrelVariable()
        Returns the name of the variable which is to be implicitly set at runtime each time a row is returned from the first input of this relational expression; or null if there is no variable.
        Returns:
        Name of correlating variable, or null
      • isDistinct

        @Deprecated
        boolean isDistinct()
        Returns whether the same value will not come out twice. Default value is false, derived classes should override.
        Returns:
        Whether the same value will not come out twice
      • getInput

        RelNode getInput​(int i)
        Returns the ith input relational expression.
        Parameters:
        i - Ordinal of input
        Returns:
        ith input
      • getQuery

        @Deprecated
        RelOptQuery getQuery()
        Deprecated.
        Returns the sub-query this relational expression belongs to.
        Returns:
        Sub-query
      • getRowType

        RelDataType getRowType()
        Returns the type of the rows returned by this relational expression.
        Specified by:
        getRowType in interface RelOptNode
      • getExpectedInputRowType

        RelDataType getExpectedInputRowType​(int ordinalInParent)
        Returns the type of the rows expected for an input. Defaults to getRowType().
        Parameters:
        ordinalInParent - input's 0-based ordinal with respect to this parent rel
        Returns:
        expected row type
      • getInputs

        java.util.List<RelNode> getInputs()
        Returns an array of this relational expression's inputs. If there are no inputs, returns an empty list, not null.
        Specified by:
        getInputs in interface RelOptNode
        Returns:
        Array of this relational expression's inputs
      • estimateRowCount

        double estimateRowCount​(RelMetadataQuery mq)
        Returns an estimate of the number of rows this relational expression will return.

        NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getRowCount(org.apache.calcite.rel.RelNode), which gives plugins a chance to override the rel's default ideas about row count.

        Parameters:
        mq - Metadata query
        Returns:
        Estimate of the number of rows this relational expression will return
      • getVariablesStopped

        @Deprecated
        java.util.Set<java.lang.String> getVariablesStopped()
        Returns the names of variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.

        Note: only Correlate should set variables.

        Note: getVariablesSet() is equivalent but returns CorrelationId rather than their names. It is preferable except for calling old methods that require a set of strings.

        Returns:
        Names of variables which are set in this relational expression
      • getVariablesSet

        java.util.Set<CorrelationId> getVariablesSet()
        Returns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.

        Note: only Correlate should set variables.

        Returns:
        Names of variables which are set in this relational expression
      • collectVariablesUsed

        void collectVariablesUsed​(java.util.Set<CorrelationId> variableSet)
        Collects variables known to be used by this expression or its descendants. By default, no such information is available and must be derived by analyzing sub-expressions, but some optimizer implementations may insert special expressions which remember such information.
        Parameters:
        variableSet - receives variables used
      • collectVariablesSet

        void collectVariablesSet​(java.util.Set<CorrelationId> variableSet)
        Collects variables set by this expression. TODO: is this required?
        Parameters:
        variableSet - receives variables known to be set by
      • childrenAccept

        void childrenAccept​(RelVisitor visitor)
        Interacts with the RelVisitor in a visitor pattern to traverse the tree of relational expressions.
        Parameters:
        visitor - Visitor that will traverse the tree of relational expressions
      • computeSelfCost

        RelOptCost computeSelfCost​(RelOptPlanner planner,
                                   RelMetadataQuery mq)
        Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.

        NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getNonCumulativeCost(org.apache.calcite.rel.RelNode), which gives plugins a chance to override the rel's default ideas about cost.

        Parameters:
        planner - Planner for cost calculation
        mq - Metadata query
        Returns:
        Cost of this plan (not including children)
      • metadata

        <M extends Metadata> M metadata​(java.lang.Class<M> metadataClass,
                                        RelMetadataQuery mq)
        Returns a metadata interface.
        Type Parameters:
        M - Type of metadata being requested
        Parameters:
        metadataClass - Metadata interface
        mq - Metadata query
        Returns:
        Metadata object that supplies the desired metadata (never null, although if the information is not present the metadata object may return null from all methods)
      • onRegister

        RelNode onRegister​(RelOptPlanner planner)
        Receives notification that this expression is about to be registered. The implementation of this method must at least register all child expressions.
        Parameters:
        planner - Planner that plans this relational node
        Returns:
        Relational expression that should be used by the planner
      • recomputeDigest

        java.lang.String recomputeDigest()
        Computes the digest, assigns it, and returns it. For planner use only.
        Returns:
        Digest of this relational expression
      • replaceInput

        void replaceInput​(int ordinalInParent,
                          RelNode p)
        Replaces the ordinalInParentth input. You must override this method if you override getInputs().
        Parameters:
        ordinalInParent - Position of the child input, 0 is the first
        p - New node that should be put at position ordinalInParent
      • getTable

        RelOptTable getTable()
        If this relational expression represents an access to a table, returns that table, otherwise returns null.
        Returns:
        If this relational expression represents an access to a table, returns that table, otherwise returns null
      • getRelTypeName

        java.lang.String getRelTypeName()
        Returns the name of this relational expression's class, sans package name, for use in explain. For example, for a org.apache.calcite.rel.ArrayRel.ArrayReader, this method returns "ArrayReader".
        Returns:
        Name of this relational expression's class, sans package name, for use in explain
      • isValid

        boolean isValid​(Litmus litmus,
                        RelNode.Context context)
        Returns whether this relational expression is valid.

        If assertions are enabled, this method is typically called with litmus = THROW, as follows:

        assert rel.isValid(Litmus.THROW)

        This signals that the method can throw an AssertionError if it is not valid.

        Parameters:
        litmus - What to do if invalid
        context - Context for validity checking
        Returns:
        Whether relational expression is valid
        Throws:
        java.lang.AssertionError - if this relational expression is invalid and litmus is THROW
      • isValid

        @Deprecated
        boolean isValid​(boolean fail)
        Deprecated.
      • getCollationList

        @Deprecated
        java.util.List<RelCollation> getCollationList()
        Returns a description of the physical ordering (or orderings) of this relational expression. Never null.
        Returns:
        Description of the physical ordering (or orderings) of this relational expression. Never null
      • copy

        RelNode copy​(RelTraitSet traitSet,
                     java.util.List<RelNode> inputs)
        Creates a copy of this relational expression, perhaps changing traits and inputs.

        Sub-classes with other important attributes are encouraged to create variants of this method with more parameters.

        Parameters:
        traitSet - Trait set
        inputs - Inputs
        Returns:
        Copy of this relational expression, substituting traits and inputs
      • register

        void register​(RelOptPlanner planner)
        Registers any special rules specific to this kind of relational expression.

        The planner calls this method this first time that it sees a relational expression of this class. The derived class should call RelOptPlanner.addRule(org.apache.calcite.plan.RelOptRule) for each rule, and then call super.register.

        Parameters:
        planner - Planner to be used to register additional relational expressions
      • isKey

        @Deprecated
        boolean isKey​(ImmutableBitSet columns)
        Returns whether the result of this relational expression is uniquely identified by this columns with the given ordinals.

        For example, if this relational expression is a LogicalTableScan to T(A, B, C, D) whose key is (A, B), then isKey([0, 1]) yields true, and isKey([0]) and isKey([0, 2]) yields false.

        Parameters:
        columns - Ordinals of key columns
        Returns:
        Whether the given columns are a key or a superset of a key
      • accept

        RelNode accept​(RelShuttle shuttle)
        Accepts a visit from a shuttle.
        Parameters:
        shuttle - Shuttle
        Returns:
        A copy of this node incorporating changes made by the shuttle to this node's children
      • accept

        RelNode accept​(RexShuttle shuttle)
        Accepts a visit from a shuttle. If the shuttle updates expression, then a copy of the relation should be created. This new relation might have a different row-type.
        Parameters:
        shuttle - Shuttle
        Returns:
        A copy of this node incorporating changes made by the shuttle to this node's children