Package org.apache.druid.query
Interface DataSource
- All Superinterfaces:
Cacheable
- All Known Implementing Classes:
FilteredDataSource,FrameBasedInlineDataSource,GlobalTableDataSource,InlineDataSource,JoinDataSource,LeafDataSource,LookupDataSource,QueryDataSource,RestrictedDataSource,TableDataSource,UnionDataSource,UnnestDataSource
Represents a source... of data... for a query. Analogous to the "FROM" clause in SQL.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final byte -
Method Summary
Modifier and TypeMethodDescriptioncreateSegmentMapFunction(Query query) Returns a segment function on to how to segment should be modified.byte[]Compute a cache key prefix for a data source.Returns datasources that this datasource depends on.Returns the names of all table datasources involved in this query.booleanisCacheable(boolean isBroker) Returns true if queries on this dataSource are cacheable at both the result level and per-segment level.booleanisGlobal()Decides if this datasource can be accessed globally.booleanCommunicates that thisDataSourcecan be directly used to run aQuery.withChildren(List<DataSource> children) Return a new DataSource, identical to this one, with different children.default DataSourcewithPolicies(Map<String, Optional<Policy>> policyMap, PolicyEnforcer policyEnforcer) Returns an updated datasource based on the policy restrictions on tables.
-
Field Details
-
JOIN_OPERATION_CACHE_ID
static final byte JOIN_OPERATION_CACHE_ID- See Also:
-
TABLE_DATA_SOURCE_CACHE_ID
static final byte TABLE_DATA_SOURCE_CACHE_ID- See Also:
-
NOOP_CACHE_ID
static final byte NOOP_CACHE_ID- See Also:
-
-
Method Details
-
getTableNames
Returns the names of all table datasources involved in this query. Does not include names for non-tables, like lookups or inline datasources. -
getChildren
List<DataSource> getChildren()Returns datasources that this datasource depends on. Will be empty for leaf datasources like 'table'. -
withChildren
Return a new DataSource, identical to this one, with different children. The number of children must be equal to the number of children that this datasource already has. -
isCacheable
boolean isCacheable(boolean isBroker) Returns true if queries on this dataSource are cacheable at both the result level and per-segment level. Currently, dataSources that do not actually reference segments (like 'inline'), are not cacheable since cache keys are always based on segment identifiers. -
isGlobal
boolean isGlobal()Decides if this datasource can be accessed globally.This means that all servers have a full copy of this datasource.
Examples: inline table, lookup.
-
isProcessable
boolean isProcessable()Communicates that thisDataSourcecan be directly used to run aQuery.A Processable datasource must pack the necessary logic into the
createSegmentMapFunction(Query).Processable examples are:
TableDataSource,InlineDataSource,FilteredDataSource. Non-processable ones are those which need further pre-processing before running them. examples are:QueryDataSourceand join which are not supported directly. -
createSegmentMapFunction
Returns a segment function on to how to segment should be modified. -
withPolicies
default DataSource withPolicies(Map<String, Optional<Policy>> policyMap, PolicyEnforcer policyEnforcer) Returns an updated datasource based on the policy restrictions on tables.If this datasource contains no table, no changes should occur.
- Parameters:
policyMap- a mapping of table names to policy restrictions. A missing key is different from an empty value:- a missing key means the table has never been permission checked.
- an empty value indicates the table doesn't have any policy restrictions, it has been permission checked.
policyEnforcer- the policy enforcer to enforce the result datasource complies- Returns:
- the updated datasource, with restrictions applied in the datasource tree
- Throws:
IllegalStateException- when mapping a RestrictedDataSource, unless the table has a NoRestrictionPolicy in the policyMap (used by druid-internal). Missing policy or adding a non-NoRestrictionPolicy to RestrictedDataSource would throw.
-
getCacheKey
@Nullable byte[] getCacheKey()Compute a cache key prefix for a data source. This includes the data sources that participate in the RHS of a join as well as any query specific constructs associated with join data source such as base table filter. This key prefix can be used in segment level cache or result level cache. The function can return following - Non-empty byte array - If there is join datasource involved and caching is possible. The result includes join condition expression, join type and cache key returned by joinable factory for eachPreJoinableClause- NULL - There is a join but caching is not possible. It may happen if one of the participating datasource in the JOIN is not cacheable.- Specified by:
getCacheKeyin interfaceCacheable- Returns:
- the cache key to be used as part of query cache key
-