Class ConvertCountToDirectScanPrule

java.lang.Object
org.apache.calcite.plan.RelOptRule
org.apache.drill.exec.planner.physical.Prule
org.apache.drill.exec.planner.physical.ConvertCountToDirectScanPrule

public class ConvertCountToDirectScanPrule extends Prule

This rule will convert " select count(*) as mycount from table " or " select count(not-nullable-expr) as mycount from table " into

    Project(mycount)
         \
    DirectGroupScan ( PojoRecordReader ( rowCount ))
or " select count(column) as mycount from table " into
      Project(mycount)
           \
            DirectGroupScan (PojoRecordReader (columnValueCount))
Rule can be applied if query contains multiple count expressions. " select count(column1), count(column2), count(*) from table "

Currently, only parquet group scan has the exact row count and column value count, obtained from parquet row group info. This will save the cost to scan the whole parquet files.

NOTE: This rule is a physical planning counterpart to a similar ConvertCountToDirectScanRule logical rule. However, while the logical rule relies on the Parquet metadata cache's Summary aggregates, this rule is applicable if the exact row count is available from the GroupScan regardless of where that stat came from. Hence, it is more general, with the trade-off that the GroupScan relies on the fully expanded list of row groups to compute the aggregate row count.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.calcite.plan.RelOptRule

    org.apache.calcite.plan.RelOptRule.ConverterRelOptRuleOperand
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.apache.calcite.plan.RelOptRule
     
    static final org.apache.calcite.plan.RelOptRule
     

    Fields inherited from class org.apache.calcite.plan.RelOptRule

    description, operands, relBuilderFactory
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onMatch(org.apache.calcite.plan.RelOptRuleCall call)
     

    Methods inherited from class org.apache.drill.exec.planner.physical.Prule

    convert, isSingleMode

    Methods inherited from class org.apache.calcite.plan.RelOptRule

    any, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • AGG_ON_PROJ_ON_SCAN

      public static final org.apache.calcite.plan.RelOptRule AGG_ON_PROJ_ON_SCAN
    • AGG_ON_SCAN

      public static final org.apache.calcite.plan.RelOptRule AGG_ON_SCAN
  • Method Details

    • onMatch

      public void onMatch(org.apache.calcite.plan.RelOptRuleCall call)
      Specified by:
      onMatch in class org.apache.calcite.plan.RelOptRule