Class SqlToRelConverter.Blackboard

  • All Implemented Interfaces:
    org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>, org.apache.calcite.sql2rel.InitializerContext, org.apache.calcite.sql2rel.SqlRexContext
    Enclosing class:
    SqlToRelConverter

    protected class SqlToRelConverter.Blackboard
    extends Object
    implements org.apache.calcite.sql2rel.SqlRexContext, org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>, org.apache.calcite.sql2rel.InitializerContext
    Workspace for translating an individual SELECT statement (or sub-SELECT).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      @Nullable org.apache.calcite.rel.RelNode root  
      @Nullable org.apache.calcite.sql.validate.SqlValidatorScope scope
      Collection of RelNode objects which correspond to a SELECT statement.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Blackboard​(@Nullable org.apache.calcite.sql.validate.SqlValidatorScope scope, @Nullable Map<String,​org.apache.calcite.rex.RexNode> nameToNodeMap, boolean top)
      Creates a Blackboard.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      org.apache.calcite.rex.RexNode convertExpression​(org.apache.calcite.sql.SqlNode expr)  
      org.apache.calcite.rex.RexNode convertInterval​(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier)  
      org.apache.calcite.rex.RexNode convertLiteral​(org.apache.calcite.sql.SqlLiteral literal)  
      org.apache.calcite.rex.RexFieldCollation convertSortExpression​(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.rel.RelFieldCollation.Direction direction, org.apache.calcite.rel.RelFieldCollation.NullDirection nullDirection)
      Deprecated.
      void flatten​(List<org.apache.calcite.rel.RelNode> rels, int systemFieldCount, int[] start, List<org.apache.calcite.util.Pair<org.apache.calcite.rel.RelNode,​Integer>> relOffsetList)  
      List<org.apache.calcite.sql.validate.SqlMonotonicity> getColumnMonotonicities()  
      int getGroupCount()  
      org.apache.calcite.sql2rel.InitializerExpressionFactory getInitializerExpressionFactory()  
      org.apache.calcite.rex.RexBuilder getRexBuilder()  
      org.apache.calcite.rex.RexRangeRef getSubQueryExpr​(org.apache.calcite.sql.SqlCall call)  
      org.apache.calcite.rel.type.RelDataTypeFactory getTypeFactory()  
      org.apache.calcite.sql.validate.SqlValidator getValidator()  
      org.apache.calcite.rex.RexNode register​(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.core.JoinRelType joinType)  
      org.apache.calcite.rex.RexNode register​(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.core.JoinRelType joinType, @Nullable List<org.apache.calcite.rex.RexNode> leftKeys)
      Registers a relational expression.
      org.apache.calcite.rel.RelNode reRegister​(org.apache.calcite.rel.RelNode root)
      Re-register the registered with given root node and return the new root node.
      org.apache.calcite.rel.RelNode root()  
      org.apache.calcite.sql.validate.SqlValidatorScope scope()  
      void setDataset​(@Nullable String datasetName)
      Notifies this Blackboard that the root just set using setRoot(RelNode, boolean) was derived using dataset substitution.
      void setPatternVarRef​(boolean isVarRef)  
      void setRoot​(org.apache.calcite.rel.RelNode root, boolean leaf)
      Sets a new root relational expression, as the translation process backs its way further up the tree.
      org.apache.calcite.sql.SqlNode validateExpression​(org.apache.calcite.rel.type.RelDataType rowType, org.apache.calcite.sql.SqlNode expr)  
      org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlCall call)  
      org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlDataTypeSpec type)  
      org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlDynamicParam param)  
      org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlIdentifier id)  
      org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier)  
      org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlLiteral literal)  
      org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlNodeList nodeList)  
      • Methods inherited from interface org.apache.calcite.sql2rel.InitializerContext

        parseExpression
      • Methods inherited from interface org.apache.calcite.sql.util.SqlVisitor

        visitNode
    • Field Detail

      • scope

        public final @Nullable org.apache.calcite.sql.validate.SqlValidatorScope scope
        Collection of RelNode objects which correspond to a SELECT statement.
      • root

        public @Nullable org.apache.calcite.rel.RelNode root
    • Constructor Detail

      • Blackboard

        protected Blackboard​(@Nullable org.apache.calcite.sql.validate.SqlValidatorScope scope,
                             @Nullable Map<String,​org.apache.calcite.rex.RexNode> nameToNodeMap,
                             boolean top)
        Creates a Blackboard.
        Parameters:
        scope - Name-resolution scope for expressions validated within this query. Can be null if this Blackboard is for a leaf node, say
        nameToNodeMap - Map which translates the expression to map a given parameter into, if translating expressions; null otherwise
        top - Whether this is the root of the query
    • Method Detail

      • root

        public org.apache.calcite.rel.RelNode root()
      • scope

        public org.apache.calcite.sql.validate.SqlValidatorScope scope()
      • setPatternVarRef

        public void setPatternVarRef​(boolean isVarRef)
      • register

        public org.apache.calcite.rex.RexNode register​(org.apache.calcite.rel.RelNode rel,
                                                       org.apache.calcite.rel.core.JoinRelType joinType)
      • register

        public org.apache.calcite.rex.RexNode register​(org.apache.calcite.rel.RelNode rel,
                                                       org.apache.calcite.rel.core.JoinRelType joinType,
                                                       @Nullable List<org.apache.calcite.rex.RexNode> leftKeys)
        Registers a relational expression.
        Parameters:
        rel - Relational expression
        joinType - Join type
        leftKeys - LHS of IN clause, or null for expressions other than IN
        Returns:
        Expression with which to refer to the row (or partial row) coming from this relational expression's side of the join
      • reRegister

        public org.apache.calcite.rel.RelNode reRegister​(org.apache.calcite.rel.RelNode root)
        Re-register the registered with given root node and return the new root node.
        Parameters:
        root - The given root, never leaf
        Returns:
        new root after the registration
      • setRoot

        public void setRoot​(org.apache.calcite.rel.RelNode root,
                            boolean leaf)
        Sets a new root relational expression, as the translation process backs its way further up the tree.
        Parameters:
        root - New root relational expression
        leaf - Whether the relational expression is a leaf, that is, derived from an atomic relational expression such as a table name in the from clause, or the projection on top of a select-sub-query. In particular, relational expressions derived from JOIN operators are not leaves, but set expressions are.
      • setDataset

        public void setDataset​(@Nullable String datasetName)
        Notifies this Blackboard that the root just set using setRoot(RelNode, boolean) was derived using dataset substitution.

        The default implementation is not interested in such notifications, and does nothing.

        Parameters:
        datasetName - Dataset name
      • flatten

        public void flatten​(List<org.apache.calcite.rel.RelNode> rels,
                            int systemFieldCount,
                            int[] start,
                            List<org.apache.calcite.util.Pair<org.apache.calcite.rel.RelNode,​Integer>> relOffsetList)
      • convertExpression

        public org.apache.calcite.rex.RexNode convertExpression​(org.apache.calcite.sql.SqlNode expr)
        Specified by:
        convertExpression in interface org.apache.calcite.sql2rel.InitializerContext
        Specified by:
        convertExpression in interface org.apache.calcite.sql2rel.SqlRexContext
      • convertSortExpression

        @Deprecated
        public org.apache.calcite.rex.RexFieldCollation convertSortExpression​(org.apache.calcite.sql.SqlNode expr,
                                                                              org.apache.calcite.rel.RelFieldCollation.Direction direction,
                                                                              org.apache.calcite.rel.RelFieldCollation.NullDirection nullDirection)
        Deprecated.
        Converts an item in an ORDER BY clause inside a window (OVER) clause, extracting DESC, NULLS LAST and NULLS FIRST flags first.
      • getGroupCount

        public int getGroupCount()
        Specified by:
        getGroupCount in interface org.apache.calcite.sql2rel.SqlRexContext
      • getRexBuilder

        public org.apache.calcite.rex.RexBuilder getRexBuilder()
        Specified by:
        getRexBuilder in interface org.apache.calcite.sql2rel.InitializerContext
        Specified by:
        getRexBuilder in interface org.apache.calcite.sql2rel.SqlRexContext
      • validateExpression

        public org.apache.calcite.sql.SqlNode validateExpression​(org.apache.calcite.rel.type.RelDataType rowType,
                                                                 org.apache.calcite.sql.SqlNode expr)
        Specified by:
        validateExpression in interface org.apache.calcite.sql2rel.InitializerContext
      • getSubQueryExpr

        public org.apache.calcite.rex.RexRangeRef getSubQueryExpr​(org.apache.calcite.sql.SqlCall call)
        Specified by:
        getSubQueryExpr in interface org.apache.calcite.sql2rel.SqlRexContext
      • getTypeFactory

        public org.apache.calcite.rel.type.RelDataTypeFactory getTypeFactory()
        Specified by:
        getTypeFactory in interface org.apache.calcite.sql2rel.SqlRexContext
      • getInitializerExpressionFactory

        public org.apache.calcite.sql2rel.InitializerExpressionFactory getInitializerExpressionFactory()
        Specified by:
        getInitializerExpressionFactory in interface org.apache.calcite.sql2rel.SqlRexContext
      • getValidator

        public org.apache.calcite.sql.validate.SqlValidator getValidator()
        Specified by:
        getValidator in interface org.apache.calcite.sql2rel.SqlRexContext
      • convertLiteral

        public org.apache.calcite.rex.RexNode convertLiteral​(org.apache.calcite.sql.SqlLiteral literal)
        Specified by:
        convertLiteral in interface org.apache.calcite.sql2rel.SqlRexContext
      • convertInterval

        public org.apache.calcite.rex.RexNode convertInterval​(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier)
      • visit

        public org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlLiteral literal)
        Specified by:
        visit in interface org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
      • visit

        public org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlCall call)
        Specified by:
        visit in interface org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
      • visit

        public org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlNodeList nodeList)
        Specified by:
        visit in interface org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
      • visit

        public org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlIdentifier id)
        Specified by:
        visit in interface org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
      • visit

        public org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlDataTypeSpec type)
        Specified by:
        visit in interface org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
      • visit

        public org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlDynamicParam param)
        Specified by:
        visit in interface org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
      • visit

        public org.apache.calcite.rex.RexNode visit​(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier)
        Specified by:
        visit in interface org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
      • getColumnMonotonicities

        public List<org.apache.calcite.sql.validate.SqlMonotonicity> getColumnMonotonicities()