Class DrillRelOptUtil

java.lang.Object
org.apache.drill.exec.planner.common.DrillRelOptUtil

public abstract class DrillRelOptUtil extends Object
Utility class that is a subset of the RelOptUtil class and is a placeholder for Drill specific static methods that are needed during either logical or physical planning.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    InputRefVisitor is a utility class used to collect all the RexInputRef nodes in a RexNode.
    static class 
    Stores information about fields, their names and types.
    static class 
    RexFieldsTransformer is a utility class used to convert column refs in a RexNode based on inputRefMap (input to output ref map).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<org.apache.calcite.util.Pair<Integer,Integer>>
    analyzeSimpleEquiJoin(org.apache.calcite.rel.core.Join join)
     
    static boolean
    analyzeSimpleEquiJoin(org.apache.calcite.rel.core.Join join, int[] joinFieldOrdinals)
    Returns whether the join condition is a simple equi-join or not.
    static boolean
    areRowTypesCompatible(org.apache.calcite.rel.type.RelDataType rowType1, org.apache.calcite.rel.type.RelDataType rowType2, boolean compareNames, boolean allowSubstring)
     
    static org.apache.calcite.rel.RelNode
    createRename(org.apache.calcite.rel.RelNode rel, List<String> fieldNames)
    Returns a relational expression which has the same fields as the underlying expression, but the fields have different names.
    static List<org.apache.calcite.rex.RexInputRef>
    findAllRexInputRefs(org.apache.calcite.rex.RexNode node)
     
    static org.apache.calcite.rex.RexCall
    findOperators(org.apache.calcite.rex.RexNode node, List<org.apache.calcite.rex.RexNode> projExprs, Collection<String> operators)
    Travesal RexNode to find at least one operator in the given collection.
    static org.apache.calcite.rel.core.TableScan
    findScan(org.apache.calcite.rel.RelNode... rels)
     
    static DrillTable
    getDrillTable(org.apache.calcite.rel.RelNode scan)
     
    getFieldsInformation(org.apache.calcite.rel.type.RelDataType rowType, List<org.apache.calcite.rex.RexNode> projects)
     
    static boolean
    guessRows(org.apache.calcite.rel.RelNode rel)
    Returns whether statistics-based estimates or guesses are used by the optimizer for the RelNode rel.
    static boolean
    isLimit0(org.apache.calcite.rex.RexNode fetch)
     
    static boolean
    isProjectFlatten(org.apache.calcite.rel.RelNode relNode)
     
    static boolean
    isProjectOutputRowcountUnknown(org.apache.calcite.rel.core.Project project)
    Find whether the given project rel can produce non-scalar output (hence unknown rowcount).
    static boolean
    isProjectOutputSchemaUnknown(org.apache.calcite.rel.core.Project project)
    Find whether the given project rel has unknown output schema.
    static boolean
    isTrivialProject(org.apache.calcite.rel.core.Project project, boolean useNamesInIdentityProjCalc)
     
    rightShiftColsInRowType(org.apache.calcite.rel.type.RelDataType rowType)
    For a given row type return a map between old field indices and one index right shifted fields.
    static org.apache.calcite.rex.RexNode
    transformExpr(org.apache.calcite.rex.RexBuilder builder, org.apache.calcite.rex.RexNode expr, Map<Integer,Integer> corrMap)
    Given a of rexnode it transforms the rexnode by changing the expr to use new index mapped to the old index.
    static List<org.apache.calcite.rex.RexNode>
    transformExprs(org.apache.calcite.rex.RexBuilder builder, List<org.apache.calcite.rex.RexNode> exprs, Map<Integer,Integer> corrMap)
    Given a list of rexnodes it transforms the rexnodes by changing the expr to use new index mapped to the old index.
    static org.apache.calcite.rel.type.RelDataType
    uniqifyFieldName(org.apache.calcite.rel.type.RelDataType rowType, org.apache.calcite.rel.type.RelDataTypeFactory typeFactory)
    Returns a rowType having all unique field name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • DrillRelOptUtil

      public DrillRelOptUtil()
  • Method Details

    • areRowTypesCompatible

      public static boolean areRowTypesCompatible(org.apache.calcite.rel.type.RelDataType rowType1, org.apache.calcite.rel.type.RelDataType rowType2, boolean compareNames, boolean allowSubstring)
    • createRename

      public static org.apache.calcite.rel.RelNode createRename(org.apache.calcite.rel.RelNode rel, List<String> fieldNames)
      Returns a relational expression which has the same fields as the underlying expression, but the fields have different names.
      Parameters:
      rel - Relational expression
      fieldNames - Field names
      Returns:
      Renamed relational expression
    • isTrivialProject

      public static boolean isTrivialProject(org.apache.calcite.rel.core.Project project, boolean useNamesInIdentityProjCalc)
    • uniqifyFieldName

      public static org.apache.calcite.rel.type.RelDataType uniqifyFieldName(org.apache.calcite.rel.type.RelDataType rowType, org.apache.calcite.rel.type.RelDataTypeFactory typeFactory)
      Returns a rowType having all unique field name.
      Parameters:
      rowType - input rowType
      typeFactory - type factory used to create a new row type.
      Returns:
      a rowType having all unique field name.
    • findOperators

      public static org.apache.calcite.rex.RexCall findOperators(org.apache.calcite.rex.RexNode node, List<org.apache.calcite.rex.RexNode> projExprs, Collection<String> operators)
      Travesal RexNode to find at least one operator in the given collection. Continue search if RexNode has a RexInputRef which refers to a RexNode in project expressions.
      Parameters:
      node - RexNode to search
      projExprs - the list of project expressions. Empty list means there is No project operator underneath.
      operators - collection of operators to find
      Returns:
      Return null if there is NONE; return the first appearance of item/flatten RexCall.
    • isLimit0

      public static boolean isLimit0(org.apache.calcite.rex.RexNode fetch)
    • isProjectOutputRowcountUnknown

      public static boolean isProjectOutputRowcountUnknown(org.apache.calcite.rel.core.Project project)
      Find whether the given project rel can produce non-scalar output (hence unknown rowcount). This would happen if the project has a flatten
      Parameters:
      project - The project rel
      Returns:
      Return true if the rowcount is unknown. Otherwise, false.
    • isProjectOutputSchemaUnknown

      public static boolean isProjectOutputSchemaUnknown(org.apache.calcite.rel.core.Project project)
      Find whether the given project rel has unknown output schema. This would happen if the project has CONVERT_FROMJSON which can only derive the schema after evaluation is performed
      Parameters:
      project - The project rel
      Returns:
      Return true if the project output schema is unknown. Otherwise, false.
    • findScan

      public static org.apache.calcite.rel.core.TableScan findScan(org.apache.calcite.rel.RelNode... rels)
    • rightShiftColsInRowType

      public static Map<Integer,Integer> rightShiftColsInRowType(org.apache.calcite.rel.type.RelDataType rowType)
      For a given row type return a map between old field indices and one index right shifted fields.
      Parameters:
      rowType - row type to be right shifted.
      Returns:
      map hash map between old and new indices
    • transformExprs

      public static List<org.apache.calcite.rex.RexNode> transformExprs(org.apache.calcite.rex.RexBuilder builder, List<org.apache.calcite.rex.RexNode> exprs, Map<Integer,Integer> corrMap)
      Given a list of rexnodes it transforms the rexnodes by changing the expr to use new index mapped to the old index.
      Parameters:
      builder - RexBuilder from the planner.
      exprs - RexNodes to be transformed.
      corrMap - Mapping between old index to new index.
      Returns:
      list of transformed expressions
    • transformExpr

      public static org.apache.calcite.rex.RexNode transformExpr(org.apache.calcite.rex.RexBuilder builder, org.apache.calcite.rex.RexNode expr, Map<Integer,Integer> corrMap)
      Given a of rexnode it transforms the rexnode by changing the expr to use new index mapped to the old index.
      Parameters:
      builder - RexBuilder from the planner.
      expr - RexNode to be transformed.
      corrMap - Mapping between old index to new index.
      Returns:
      transformed expression
    • isProjectFlatten

      public static boolean isProjectFlatten(org.apache.calcite.rel.RelNode relNode)
    • getFieldsInformation

      public static DrillRelOptUtil.ProjectPushInfo getFieldsInformation(org.apache.calcite.rel.type.RelDataType rowType, List<org.apache.calcite.rex.RexNode> projects)
    • guessRows

      public static boolean guessRows(org.apache.calcite.rel.RelNode rel)
      Returns whether statistics-based estimates or guesses are used by the optimizer for the RelNode rel.
      Parameters:
      rel - input
      Returns:
      TRUE if the estimate is a guess, FALSE otherwise
    • analyzeSimpleEquiJoin

      public static boolean analyzeSimpleEquiJoin(org.apache.calcite.rel.core.Join join, int[] joinFieldOrdinals)
      Returns whether the join condition is a simple equi-join or not. A simple equi-join is defined as an two-table equality join (no self-join)
      Parameters:
      join - input join
      joinFieldOrdinals - join field ordinal w.r.t. the underlying inputs to the join
      Returns:
      TRUE if the join is a simple equi-join (not a self-join), FALSE otherwise
    • getDrillTable

      public static DrillTable getDrillTable(org.apache.calcite.rel.RelNode scan)
    • analyzeSimpleEquiJoin

      public static List<org.apache.calcite.util.Pair<Integer,Integer>> analyzeSimpleEquiJoin(org.apache.calcite.rel.core.Join join)
    • findAllRexInputRefs

      public static List<org.apache.calcite.rex.RexInputRef> findAllRexInputRefs(org.apache.calcite.rex.RexNode node)