Class DrillRelMdDistinctRowCount

java.lang.Object
org.apache.calcite.rel.metadata.RelMdDistinctRowCount
org.apache.drill.exec.planner.cost.DrillRelMdDistinctRowCount
All Implemented Interfaces:
org.apache.calcite.rel.metadata.MetadataHandler<org.apache.calcite.rel.metadata.BuiltInMetadata.DistinctRowCount>

public class DrillRelMdDistinctRowCount extends org.apache.calcite.rel.metadata.RelMdDistinctRowCount
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.apache.calcite.rel.metadata.RelMetadataProvider
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getDistinctRowCount(org.apache.calcite.plan.volcano.RelSubset rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.util.ImmutableBitSet groupKey, org.apache.calcite.rex.RexNode predicate)
     
    getDistinctRowCount(org.apache.calcite.rel.core.Join rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.util.ImmutableBitSet groupKey, org.apache.calcite.rex.RexNode predicate)
    We need to override this method since Calcite and Drill calculate joined row count in different ways.
    getDistinctRowCount(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.util.ImmutableBitSet groupKey, org.apache.calcite.rex.RexNode predicate)
     

    Methods inherited from class org.apache.calcite.rel.metadata.RelMdDistinctRowCount

    getDef, getDistinctRowCount, getDistinctRowCount, getDistinctRowCount, getDistinctRowCount, getDistinctRowCount, getDistinctRowCount, getDistinctRowCount, getDistinctRowCount, getDistinctRowCount

    Methods inherited from class java.lang.Object

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

    • SOURCE

      public static final org.apache.calcite.rel.metadata.RelMetadataProvider SOURCE
  • Constructor Details

    • DrillRelMdDistinctRowCount

      public DrillRelMdDistinctRowCount()
  • Method Details

    • getDistinctRowCount

      public Double getDistinctRowCount(org.apache.calcite.rel.core.Join rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.util.ImmutableBitSet groupKey, org.apache.calcite.rex.RexNode predicate)
      We need to override this method since Calcite and Drill calculate joined row count in different ways. It helps avoid a case when at the first time was used Drill join row count but at the second time Calcite row count was used. It may happen when RelMdDistinctRowCount.getDistinctRowCount(Join, RelMetadataQuery, ImmutableBitSet, RexNode) method is used and after that used another getDistinctRowCount method for parent rel, which just uses row count of input rel node (our join rel). It causes cost increase of best rel node when RelSubset#propagateCostImprovements is called. This is a part of the fix for CALCITE-2018.
      Overrides:
      getDistinctRowCount in class org.apache.calcite.rel.metadata.RelMdDistinctRowCount
    • getDistinctRowCount

      public Double getDistinctRowCount(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.util.ImmutableBitSet groupKey, org.apache.calcite.rex.RexNode predicate)
      Overrides:
      getDistinctRowCount in class org.apache.calcite.rel.metadata.RelMdDistinctRowCount
    • getDistinctRowCount

      public Double getDistinctRowCount(org.apache.calcite.plan.volcano.RelSubset rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.util.ImmutableBitSet groupKey, org.apache.calcite.rex.RexNode predicate)
      Overrides:
      getDistinctRowCount in class org.apache.calcite.rel.metadata.RelMdDistinctRowCount