Interface Query<T>
- All Known Implementing Classes:
BaseQuery,DataSourceMetadataQuery,GroupByQuery,ScanQuery,SearchQuery,SegmentMetadataQuery,SelectQuery,TimeBoundaryQuery,TimeseriesQuery,TopNQuery,UnionQuery,WindowOperatorQuery
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault QueryContextcontext()Returns the query context as aQueryContext, which provides convenience methods for accessing typed context values.Returns the context as an (immutable) map.default booleangetContextBoolean(String key, boolean defaultValue) Deprecated.default HumanReadableBytesgetContextHumanReadableBytes(String key, HumanReadableBytes defaultValue) Deprecated.usequeryContext().getContextHumanReadableBytes()instead.default <ContextType>
ContextTypegetContextValue(String key) Deprecated.usequeryContext().get<Type>()insteadorg.joda.time.DurationgetId()List<org.joda.time.Interval> default StringReturns a most specific ID of this query; if it is a subquery, this will return its subquery ID.Returns the set of columns that this query will need to access out of its datasource.com.google.common.collect.Ordering<T> Comparator that represents the order in which results are generated from theQueryRunnerFactory.createRunner(Segment)andQueryRunnerFactory.mergeRunners(QueryProcessingPool, Iterable)calls.default RowSignaturedefault RowSignaturegetResultRowSignature(RowSignature.Finalization finalization) getRunner(QuerySegmentWalker walker) default org.joda.time.IntervalReturns an interval ifgetIntervals()has only a single interval, else explodesdefault StringReturns the subQueryId of this query.org.joda.time.DateTimeZonegetType()default VirtualColumnsbooleandefault booleanSignals that the execution of this query could also transparently handle the inputQueryDataSourceas well.optimizeForSegment(PerSegmentQueryOptimizationContext optimizationContext) withDataSource(DataSource dataSource) withOverriddenContext(Map<String, Object> contextOverride) withPriority(int priority) Returns a new query, identical to this one, but with a different associatedQuerySegmentSpec.withSqlQueryId(String sqlQueryId) withSubQueryId(String subQueryId) Returns a copy of this query with a new subQueryId (seegetSubQueryId().
-
Field Details
-
DATASOURCE_METADATA
- See Also:
-
GROUP_BY
- See Also:
-
SCAN
- See Also:
-
SEARCH
- See Also:
-
SEGMENT_METADATA
- See Also:
-
SELECT
- See Also:
-
TIME_BOUNDARY
- See Also:
-
TIMESERIES
- See Also:
-
TOPN
- See Also:
-
WINDOW_OPERATOR
- See Also:
-
UNION_QUERY
- See Also:
-
-
Method Details
-
getDataSource
DataSource getDataSource() -
hasFilters
boolean hasFilters() -
getFilter
DimFilter getFilter() -
getType
String getType() -
getRunner
-
getIntervals
List<org.joda.time.Interval> getIntervals() -
getDuration
org.joda.time.Duration getDuration() -
getGranularity
Granularity getGranularity() -
getTimezone
org.joda.time.DateTimeZone getTimezone() -
getContext
Returns the context as an (immutable) map. -
context
Returns the query context as aQueryContext, which provides convenience methods for accessing typed context values. The returned instance is a view on top of the context provided bygetContext().The default implementation is for backward compatibility. Derived classes should store and return the
QueryContextdirectly. -
getContextValue
Deprecated.usequeryContext().get<Type>()insteadGet context value and cast to ContextType in an unsafe way.For safe conversion, it's recommended to use following methods 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) -
getContextBoolean
Deprecated.usequeryContext().getBoolean()instead. -
getContextHumanReadableBytes
@Deprecated default HumanReadableBytes getContextHumanReadableBytes(String key, HumanReadableBytes defaultValue) Deprecated.usequeryContext().getContextHumanReadableBytes()instead.ReturnsHumanReadableBytesfor 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.- Parameters:
key- The context key value being looked updefaultValue- The default to return if the key value doesn't exist or the context is null.- Returns:
HumanReadableBytes
-
getResultOrdering
com.google.common.collect.Ordering<T> getResultOrdering()Comparator that represents the order in which results are generated from theQueryRunnerFactory.createRunner(Segment)andQueryRunnerFactory.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 Result
} objects. Because of this, implementations should fall back to Ordering.natural()when they are given an object that is not of type T. -
withOverriddenContext
-
withQuerySegmentSpec
Returns a new query, identical to this one, but with a different associatedQuerySegmentSpec.This often changes the behavior of
getRunner(QuerySegmentWalker), since most queries inherit that method fromBaseQuery, which implements it by callingQuerySegmentSpec.lookup(org.apache.druid.query.Query<T>, org.apache.druid.query.QuerySegmentWalker). -
withId
-
getId
-
withSubQueryId
Returns a copy of this query with a new subQueryId (seegetSubQueryId(). -
withDefaultSubQueryId
-
getSubQueryId
Returns the subQueryId of this query. This is set by ClientQuerySegmentWalker (the entry point for the Broker's query stack) on any subqueries that it issues. It is null for the main query. -
withSqlQueryId
-
getSqlQueryId
-
getMostSpecificId
Returns a most specific ID of this query; if it is a subquery, this will return its subquery ID. If it is a regular query without subqueries, this will return its query ID. This method should be called after the relevant ID is assigned usingwithId(java.lang.String)orwithSubQueryId(java.lang.String). -
withDataSource
-
optimizeForSegment
-
withPriority
-
withLane
-
getVirtualColumns
-
getRequiredColumns
Returns the set of columns that this query will need to access out of its datasource.This method does not "look into" what the datasource itself is doing. For example, if a query is built on a
QueryDataSource, this method will not return the columns used by that subquery. As another example, if a query is built on aJoinDataSource, 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.
-
getSingleInterval
default org.joda.time.Interval getSingleInterval()Returns an interval ifgetIntervals()has only a single interval, else explodes -
mayCollapseQueryDataSource
default boolean mayCollapseQueryDataSource()Signals that the execution of this query could also transparently handle the inputQueryDataSourceas well. This is a not-so-nice way to support thatGroupByQuerycould collapse otherGroupByQuery-ies inQueryDataSource-es. -
getResultRowSignature
-
getResultRowSignature
-
queryContext().getBoolean()instead.