public interface Query<T>
| Modifier and Type | Field and Description |
|---|---|
static String |
DATASOURCE_METADATA |
static String |
GROUP_BY |
static String |
SCAN |
static String |
SEARCH |
static String |
SEGMENT_METADATA |
static String |
SELECT |
static String |
TIME_BOUNDARY |
static String |
TIMESERIES |
static String |
TOPN |
static String |
WINDOW_OPERATOR |
| Modifier and Type | Method and Description |
|---|---|
default QueryContext |
context()
Returns the query context as a
QueryContext, which provides
convenience methods for accessing typed context values. |
Map<String,Object> |
getContext()
Returns the context as an (immutable) map.
|
default boolean |
getContextBoolean(String key,
boolean defaultValue)
Deprecated.
use
queryContext().getBoolean() instead. |
default HumanReadableBytes |
getContextHumanReadableBytes(String key,
HumanReadableBytes defaultValue)
Deprecated.
use
queryContext().getContextHumanReadableBytes() instead. |
default <ContextType> |
getContextValue(String key)
Deprecated.
use
queryContext().get<Type>() instead |
DataSource |
getDataSource() |
org.joda.time.Duration |
getDuration() |
DimFilter |
getFilter() |
Granularity |
getGranularity() |
String |
getId() |
List<org.joda.time.Interval> |
getIntervals() |
default String |
getMostSpecificId()
Returns a most specific ID of this query; if it is a subquery, this will return its subquery ID.
|
default Set<String> |
getRequiredColumns()
Returns the set of columns that this query will need to access out of its datasource.
|
com.google.common.collect.Ordering<T> |
getResultOrdering()
Comparator that represents the order in which results are generated from the
QueryRunnerFactory.createRunner(Segment) and
QueryRunnerFactory.mergeRunners(QueryProcessingPool, Iterable) calls. |
QueryRunner<T> |
getRunner(QuerySegmentWalker walker) |
default String |
getSqlQueryId() |
String |
getSubQueryId()
Returns the subQueryId of this query.
|
org.joda.time.DateTimeZone |
getTimezone() |
String |
getType() |
default VirtualColumns |
getVirtualColumns() |
boolean |
hasFilters() |
boolean |
isDescending() |
default Query<T> |
optimizeForSegment(PerSegmentQueryOptimizationContext optimizationContext) |
Query<T> |
withDataSource(DataSource dataSource) |
default Query<T> |
withDefaultSubQueryId() |
Query<T> |
withId(String id) |
default Query<T> |
withLane(String lane) |
Query<T> |
withOverriddenContext(Map<String,Object> contextOverride) |
default Query<T> |
withPriority(int priority) |
Query<T> |
withQuerySegmentSpec(QuerySegmentSpec spec)
Returns a new query, identical to this one, but with a different associated
QuerySegmentSpec. |
default Query<T> |
withSqlQueryId(String sqlQueryId) |
Query<T> |
withSubQueryId(String subQueryId)
Returns a copy of this query with a new subQueryId (see
getSubQueryId(). |
static final String DATASOURCE_METADATA
static final String GROUP_BY
static final String SCAN
static final String SEARCH
static final String SEGMENT_METADATA
static final String SELECT
static final String TIME_BOUNDARY
static final String TIMESERIES
static final String TOPN
static final String WINDOW_OPERATOR
DataSource getDataSource()
boolean hasFilters()
DimFilter getFilter()
String getType()
QueryRunner<T> getRunner(QuerySegmentWalker walker)
List<org.joda.time.Interval> getIntervals()
org.joda.time.Duration getDuration()
Granularity getGranularity()
org.joda.time.DateTimeZone getTimezone()
default QueryContext context()
QueryContext, which provides
convenience methods for accessing typed context values. The returned
instance is a view on top of the context provided by getContext().
The default implementation is for backward compatibility. Derived classes should
store and return the QueryContext directly.
@Deprecated @Nullable default <ContextType> ContextType getContextValue(String key)
queryContext().get<Type>() instead
QueryContext.getBoolean(String)
QueryContext.getString(String)
QueryContext.getInt(String)
QueryContext.getLong(String)
QueryContext.getFloat(String)
QueryContext.getEnum(String, Class, Enum)
QueryContext.getHumanReadableBytes(String, HumanReadableBytes)
@Deprecated default boolean getContextBoolean(String key, boolean defaultValue)
queryContext().getBoolean() instead.@Deprecated default HumanReadableBytes getContextHumanReadableBytes(String key, HumanReadableBytes defaultValue)
queryContext().getContextHumanReadableBytes() instead.HumanReadableBytes for a specified context key. If the context is null or the key doesn't exist
a caller specified default value is returned. A default implementation is provided since Query is an extension
point. Extensions can choose to rely on this default to retain compatibility with core Druid.key - The context key value being looked updefaultValue - The default to return if the key value doesn't exist or the context is null.HumanReadableBytesboolean isDescending()
com.google.common.collect.Ordering<T> getResultOrdering()
QueryRunnerFactory.createRunner(Segment) and
QueryRunnerFactory.mergeRunners(QueryProcessingPool, Iterable) calls. This is used to combine streams of
results from different sources; for example, it's used by historicals to combine streams from different segments,
and it's used by the broker to combine streams from different historicals.
Important note: sometimes, this ordering is used in a type-unsafe way to order @{code ResultOrdering.natural() when they are given an
object that is not of type T.Query<T> withQuerySegmentSpec(QuerySegmentSpec spec)
QuerySegmentSpec.
This often changes the behavior of getRunner(QuerySegmentWalker), since most queries inherit that method
from BaseQuery, which implements it by calling QuerySegmentSpec.lookup(org.apache.druid.query.Query<T>, org.apache.druid.query.QuerySegmentWalker).Query<T> withSubQueryId(String subQueryId)
getSubQueryId().@Nullable String getSubQueryId()
default String getMostSpecificId()
withId(java.lang.String) or withSubQueryId(java.lang.String).Query<T> withDataSource(DataSource dataSource)
default Query<T> optimizeForSegment(PerSegmentQueryOptimizationContext optimizationContext)
default VirtualColumns getVirtualColumns()
@Nullable default Set<String> getRequiredColumns()
QueryDataSource, this method will not return the columns used by that subquery. As another example, if a
query is built on a JoinDataSource, this method will not return the columns from the underlying datasources
that are used by the join condition, unless those columns are also used by this query in other ways.
Returns null if the set of required columns cannot be known ahead of time.Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.