Class DrillRelOptUtil
java.lang.Object
org.apache.drill.exec.planner.common.DrillRelOptUtil
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 ClassesModifier and TypeClassDescriptionstatic classInputRefVisitor is a utility class used to collect all the RexInputRef nodes in a RexNode.static classStores information about fields, their names and types.static classRexFieldsTransformer is a utility class used to convert column refs in a RexNode based on inputRefMap (input to output ref map). -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionanalyzeSimpleEquiJoin(org.apache.calcite.rel.core.Join join) static booleananalyzeSimpleEquiJoin(org.apache.calcite.rel.core.Join join, int[] joinFieldOrdinals) Returns whether the join condition is a simple equi-join or not.static booleanareRowTypesCompatible(org.apache.calcite.rel.type.RelDataType rowType1, org.apache.calcite.rel.type.RelDataType rowType2, boolean compareNames, boolean allowSubstring) static org.apache.calcite.rel.RelNodecreateRename(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.RexCallfindOperators(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.TableScanfindScan(org.apache.calcite.rel.RelNode... rels) static DrillTablegetDrillTable(org.apache.calcite.rel.RelNode scan) getFieldsInformation(org.apache.calcite.rel.type.RelDataType rowType, List<org.apache.calcite.rex.RexNode> projects) static booleanguessRows(org.apache.calcite.rel.RelNode rel) Returns whether statistics-based estimates or guesses are used by the optimizer for theRelNoderel.static booleanisLimit0(org.apache.calcite.rex.RexNode fetch) static booleanisProjectFlatten(org.apache.calcite.rel.RelNode relNode) static booleanisProjectOutputRowcountUnknown(org.apache.calcite.rel.core.Project project) Find whether the given project rel can produce non-scalar output (hence unknown rowcount).static booleanisProjectOutputSchemaUnknown(org.apache.calcite.rel.core.Project project) Find whether the given project rel has unknown output schema.static booleanisTrivialProject(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.RexNodetransformExpr(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.RelDataTypeuniqifyFieldName(org.apache.calcite.rel.type.RelDataType rowType, org.apache.calcite.rel.type.RelDataTypeFactory typeFactory) Returns a rowType having all unique field name.
-
Field Details
-
IMPLICIT_COLUMN
- See Also:
-
-
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 expressionfieldNames- 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 rowTypetypeFactory- 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 searchprojExprs- 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 theRelNoderel.- 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 joinjoinFieldOrdinals- 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
-
analyzeSimpleEquiJoin
-
findAllRexInputRefs
public static List<org.apache.calcite.rex.RexInputRef> findAllRexInputRefs(org.apache.calcite.rex.RexNode node)
-