Class CountToDirectScanUtils
java.lang.Object
org.apache.drill.exec.planner.common.CountToDirectScanUtils
A utility class that contains helper functions used by rules that convert COUNT(*) and COUNT(col)
aggregates (no group-by) to DirectScan
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic LinkedHashMap<String,
Class<?>> buildSchema
(List<String> fieldNames) Builds schema based on given field names.static org.apache.calcite.rel.type.RelDataType
constructDataType
(org.apache.calcite.rel.core.Aggregate aggregateRel, Collection<String> fieldNames) For each aggregate call creates field based on its name with bigint type.static boolean
containsStarOrNotNullInput
(org.apache.calcite.rel.core.AggregateCall aggregateCall, org.apache.calcite.rel.core.Aggregate aggregate) Checks if aggregate call contains star or non-null expression:static List<org.apache.calcite.rex.RexNode>
prepareFieldExpressions
(org.apache.calcite.rel.type.RelDataType rowType) For each field creates row expression.
-
Constructor Details
-
CountToDirectScanUtils
public CountToDirectScanUtils()
-
-
Method Details
-
containsStarOrNotNullInput
public static boolean containsStarOrNotNullInput(org.apache.calcite.rel.core.AggregateCall aggregateCall, org.apache.calcite.rel.core.Aggregate aggregate) Checks if aggregate call contains star or non-null expression:count(*) == > empty arg ==> rowCount count(Not-null-input) ==> rowCount
- Parameters:
aggregateCall
- aggregate callaggregate
- aggregate relation expression- Returns:
- true of aggregate call contains star or non-null expression
-
constructDataType
public static org.apache.calcite.rel.type.RelDataType constructDataType(org.apache.calcite.rel.core.Aggregate aggregateRel, Collection<String> fieldNames) For each aggregate call creates field based on its name with bigint type. Constructs record type for created fields.- Parameters:
aggregateRel
- aggregate relation expressionfieldNames
- field names- Returns:
- record type
-
buildSchema
Builds schema based on given field names. Type for each schema is set to long.class.- Parameters:
fieldNames
- field names- Returns:
- schema
-
prepareFieldExpressions
public static List<org.apache.calcite.rex.RexNode> prepareFieldExpressions(org.apache.calcite.rel.type.RelDataType rowType) For each field creates row expression.- Parameters:
rowType
- row type- Returns:
- list of row expressions
-