Package org.apache.calcite.adapter.druid
Class DruidTable
java.lang.Object
org.apache.calcite.schema.impl.AbstractTable
org.apache.calcite.adapter.druid.DruidTable
- All Implemented Interfaces:
Table
,TranslatableTable
,Wrapper
Table mapped onto a Druid table.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDruidTable
(DruidSchema schema, String dataSource, @Nullable RelProtoDataType protoRowType, Set<String> metricFieldNames, String timestampFieldName, @Nullable List<org.joda.time.Interval> intervals, @Nullable Map<String, List<ComplexMetric>> complexMetrics, @Nullable Map<String, SqlTypeName> allFields) Creates a Druid table. -
Method Summary
Modifier and TypeMethodDescriptiongetComplexMetricsFrom
(String alias) Returns the list ofComplexMetric
that match the givenalias
if it exists, otherwise returns an empty list, nevernull
.getRowType
(RelDataTypeFactory typeFactory) Returns this table's row type.boolean
isComplexMetric
(String alias) Returns whether the givenalias
is a reference to a registeredComplexMetric
.boolean
boolean
isRolledUp
(String column) Determines whether the givencolumn
has been rolled up.@Nullable ComplexMetric
resolveComplexMetric
(String alias, AggregateCall call) Returns the appropriateComplexMetric
that is mapped from the givenalias
if it exists, and is used in the expected context with the givenAggregateCall
.boolean
rolledUpColumnValidInsideAgg
(String column, SqlCall call, @Nullable SqlNode parent, @Nullable CalciteConnectionConfig config) Determines whether the given rolled up column can be used inside the given aggregate function.toRel
(RelOptTable.ToRelContext context, RelOptTable relOptTable) Converts this table into arelational expression
.Methods inherited from class org.apache.calcite.schema.impl.AbstractTable
getJdbcTableType, getStatistic, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.schema.Table
getJdbcTableType, getStatistic
Methods inherited from interface org.apache.calcite.schema.Wrapper
maybeUnwrap, unwrapOrThrow
-
Field Details
-
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, @Nullable RelProtoDataType protoRowType, Set<String> metricFieldNames, String timestampFieldName, @Nullable List<org.joda.time.Interval> intervals, @Nullable Map<String, List<ComplexMetric>> complexMetrics, @Nullable Map<String, SqlTypeName> allFields) Creates a Druid table.- Parameters:
schema
- Druid schema that contains this tabledataSource
- Druid data source nameprotoRowType
- Field names and typesmetricFieldNames
- Names of fields that are metricstimestampFieldName
- Name of the column that contains the timeintervals
- Default interval if query does not constrain the time, or null
-
-
Method Details
-
resolveComplexMetric
Returns the appropriateComplexMetric
that is mapped from the givenalias
if it exists, and is used in the expected context with the givenAggregateCall
. Otherwise, returnsnull
. -
isRolledUp
Description copied from interface:Table
Determines whether the givencolumn
has been rolled up.- Specified by:
isRolledUp
in interfaceTable
- Overrides:
isRolledUp
in classAbstractTable
-
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 thatisRolledUp(column)
istrue
.- Specified by:
rolledUpColumnValidInsideAgg
in interfaceTable
- Overrides:
rolledUpColumnValidInsideAgg
in classAbstractTable
- Parameters:
column
- The column name for whichisRolledUp
is truecall
- The aggregate callparent
- Parent node ofcall
in theSqlNode
treeconfig
- Config settings. May be null- Returns:
- true iff the given aggregate call is valid
-
getComplexMetricsFrom
Returns the list ofComplexMetric
that match the givenalias
if it exists, otherwise returns an empty list, nevernull
. -
isComplexMetric
Returns whether the givenalias
is a reference to a registeredComplexMetric
. -
getRowType
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 interfaceTable
- Parameters:
typeFactory
- Type factory with which to create the type- Returns:
- Row type
-
toRel
Description copied from interface:TranslatableTable
Converts this table into arelational expression
.- Specified by:
toRel
in interfaceTranslatableTable
-
isMetric
-