Class DrillStatsTable

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

public class DrillStatsTable extends Object
Wraps the stats table info including schema and tableName. Also materializes stats from storage and keeps them in memory.
  • Field Details

  • Constructor Details

  • Method Details

    • getSchemaName

      public String getSchemaName()
    • getTableName

      public String getTableName()
    • isMaterialized

      public boolean isMaterialized()
    • getNdv

      public Double getNdv(SchemaPath col)
      Get the approximate number of distinct values of given column. If stats are not present for the given column, a null is returned. Note: returned data may not be accurate. Accuracy depends on whether the table data has changed after the stats are computed.
      Parameters:
      col - - column for which approximate count distinct is desired
      Returns:
      approximate count distinct of the column, if available. NULL otherwise.
    • getColumns

      public Set<SchemaPath> getColumns()
    • getRowCount

      public Double getRowCount()
      Get row count of the table. Returns null if stats are not present. Note: returned data may not be accurate. Accuracy depends on whether the table data has changed after the stats are computed.
      Returns:
      rowcount for the table, if available. NULL otherwise.
    • getNNRowCount

      public Double getNNRowCount(SchemaPath col)
      Get non-null rowcount for the column If stats are not present for the given column, a null is returned. Note: returned data may not be accurate. Accuracy depends on whether the table data has changed after the stats are computed.
      Parameters:
      col - - column for which non-null rowcount is desired
      Returns:
      non-null rowcount of the column, if available. NULL otherwise.
    • getHistogram

      public Histogram getHistogram(SchemaPath column)
      Get the histogram of a given column. If stats are not present for the given column, a null is returned.

      Note: returned data may not be accurate. Accuracy depends on whether the table data has changed after the stats are computed.

      Parameters:
      column - path to the column whose histogram should be obtained
      Returns:
      Histogram for this column
    • materialize

      public void materialize()
      Read the stats from storage and keep them in memory.
    • generateDirectoryStructure

      public static DrillStatsTable.TableStatistics generateDirectoryStructure(String dirComputedTime, List<DrillStatsTable.ColumnStatistics> columnStatisticsList)
    • direct

      public static PhysicalPlan direct(QueryContext context, boolean outcome, String message, Object... values)
    • notSupported

      public static PhysicalPlan notSupported(QueryContext context, String tbl)
    • notRequired

      public static PhysicalPlan notRequired(QueryContext context, String tbl)
    • getMapper

      public static com.fasterxml.jackson.databind.ObjectMapper getMapper()
      This method returns the statistics (de)serializer which can be used to (de)/serialize the DrillStatsTable.TableStatistics from/to JSON
    • getEstimatedTableStats

      public static List<StatisticsHolder<?>> getEstimatedTableStats(DrillStatsTable statsProvider)
      Returns list of StatisticsKind and statistics values obtained from specified DrillStatsTable.
      Parameters:
      statsProvider - the source of statistics
      Returns:
      list of StatisticsKind and statistics values
    • getEstimatedColumnStats

      public static List<StatisticsHolder<?>> getEstimatedColumnStats(DrillStatsTable statsProvider, SchemaPath fieldName)
      Returns list of StatisticsKind and statistics values obtained from specified DrillStatsTable for specified column.
      Parameters:
      statsProvider - the source of statistics
      fieldName - name of the columns whose statistics should be obtained
      Returns:
      list of StatisticsKind and statistics values