Class DruidTable

java.lang.Object
org.apache.calcite.schema.impl.AbstractTable
org.apache.calcite.adapter.druid.DruidTable
All Implemented Interfaces:
Table, TranslatableTable, Wrapper

public class DruidTable extends AbstractTable implements TranslatableTable
Table mapped onto a Druid table.
  • Field Details

    • DEFAULT_TIMESTAMP_COLUMN

      public static final String DEFAULT_TIMESTAMP_COLUMN
      See Also:
    • DEFAULT_INTERVAL

      public static final org.joda.time.Interval DEFAULT_INTERVAL
  • Constructor Details

    • DruidTable

      public DruidTable(DruidSchema schema, String dataSource, RelProtoDataType protoRowType, Set<String> metricFieldNames, String timestampFieldName, List<org.joda.time.Interval> intervals, Map<String,List<ComplexMetric>> complexMetrics, Map<String,SqlTypeName> allFields)
      Creates a Druid table.
      Parameters:
      schema - Druid schema that contains this table
      dataSource - Druid data source name
      protoRowType - Field names and types
      metricFieldNames - Names of fields that are metrics
      timestampFieldName - Name of the column that contains the time
      intervals - Default interval if query does not constrain the time, or null
  • Method Details

    • resolveComplexMetric

      public ComplexMetric resolveComplexMetric(String alias, AggregateCall call)
      Returns the appropriate ComplexMetric that is mapped from the given alias if it exists, and is used in the expected context with the given AggregateCall. Otherwise returns null.
    • isRolledUp

      public boolean isRolledUp(String column)
      Description copied from interface: Table
      Determines whether the given column has been rolled up.
      Specified by:
      isRolledUp in interface Table
      Overrides:
      isRolledUp in class AbstractTable
    • rolledUpColumnValidInsideAgg

      public boolean rolledUpColumnValidInsideAgg(String column, SqlCall call, @Nullable SqlNode parent, @Nullable CalciteConnectionConfig config)
      Description copied from interface: Table
      Determines whether the given rolled up column can be used inside the given aggregate function. You can assume that isRolledUp(column) is true.
      Specified by:
      rolledUpColumnValidInsideAgg in interface Table
      Overrides:
      rolledUpColumnValidInsideAgg in class AbstractTable
      Parameters:
      column - The column name for which isRolledUp is true
      call - The aggregate call
      parent - Parent node of call in the SqlNode tree
      config - Config settings. May be null
      Returns:
      true iff the given aggregate call is valid
    • getComplexMetricsFrom

      public List<ComplexMetric> getComplexMetricsFrom(String alias)
      Returns the list of ComplexMetric that match the given alias if it exists, otherwise returns an empty list, never null.
    • isComplexMetric

      public boolean isComplexMetric(String alias)
      Returns whether the given alias is a reference to a registered ComplexMetric.
    • getRowType

      public RelDataType getRowType(RelDataTypeFactory typeFactory)
      Description copied from interface: Table
      Returns this table's row type.

      This is a struct type whose fields describe the names and types of the columns in this table.

      The implementer must use the type factory provided. This ensures that the type is converted into a canonical form; other equal types in the same query will use the same object.

      Specified by:
      getRowType in interface Table
      Parameters:
      typeFactory - Type factory with which to create the type
      Returns:
      Row type
    • toRel

      public RelNode toRel(RelOptTable.ToRelContext context, RelOptTable relOptTable)
      Description copied from interface: TranslatableTable
      Converts this table into a relational expression.
      Specified by:
      toRel in interface TranslatableTable
    • isMetric

      public boolean isMetric(String name)