Class JoinDataSource
- All Implemented Interfaces:
Cacheable,DataSource
Logically, this datasource contains the result of:
(1) prefixing all right-side columns with "rightPrefix" (2) then, joining the left and (prefixed) right sides using the provided type and condition
Any columns from the left-hand side that start with "rightPrefix", and are at least one character longer than the prefix, will be shadowed. It is up to the caller to ensure that no important columns are shadowed by the chosen prefix.
When analyzed by JoinDataSourceAnalysis, the right-hand side of this datasource
will become a PreJoinableClause object.
-
Field Summary
Fields inherited from interface org.apache.druid.query.DataSource
JOIN_OPERATION_CACHE_ID, NOOP_CACHE_ID, TABLE_DATA_SOURCE_CACHE_ID -
Method Summary
Modifier and TypeMethodDescriptionstatic JoinDataSourcecreate(DataSource left, DataSource right, String rightPrefix, String condition, JoinType joinType, DimFilter leftFilter, ExprMacroTable macroTable, JoinableFactoryWrapper joinableFactoryWrapper, JoinAlgorithm joinAlgorithm) Create a join dataSource from a string condition.static JoinDataSourcecreate(DataSource left, DataSource right, String rightPrefix, JoinConditionAnalysis conditionAnalysis, JoinType joinType, DimFilter leftFilter, JoinableFactoryWrapper joinableFactoryWrapper, JoinAlgorithm joinAlgorithm) Create a join dataSource from an existingJoinConditionAnalysis.static SegmentMapFunctioncreateSegmentMapFunction(List<JoinableClause> clausesToUse, Filter baseFilterToUse, JoinFilterPreAnalysis joinFilterPreAnalysis, SegmentMapFunction baseMapFn) createSegmentMapFunction(Query query) Creates a Function that maps base segments toHashJoinSegmentif needed (i.e.booleanbyte[]Compute a cache key prefix for a data source.Returns datasources that this datasource depends on.Computes the DataSourceAnalysis with join boundaries.getLeft()getRight()Returns the names of all table datasources involved in this query.Computes a set of column names for left table expressions in join condition which may already have been defined as a virtual column in the virtual column registry.inthashCode()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.toString()withChildren(List<DataSource> children) Return a new DataSource, identical to this one, with different children.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.druid.query.DataSource
withPolicies
-
Method Details
-
create
public static JoinDataSource create(DataSource left, DataSource right, String rightPrefix, String condition, JoinType joinType, @Nullable DimFilter leftFilter, ExprMacroTable macroTable, @Nullable JoinableFactoryWrapper joinableFactoryWrapper, @Nullable JoinAlgorithm joinAlgorithm) Create a join dataSource from a string condition. -
create
public static JoinDataSource create(DataSource left, DataSource right, String rightPrefix, JoinConditionAnalysis conditionAnalysis, JoinType joinType, DimFilter leftFilter, @Nullable JoinableFactoryWrapper joinableFactoryWrapper, @Nullable JoinAlgorithm joinAlgorithm) Create a join dataSource from an existingJoinConditionAnalysis. -
getTableNames
Description copied from interface:DataSourceReturns the names of all table datasources involved in this query. Does not include names for non-tables, like lookups or inline datasources.- Specified by:
getTableNamesin interfaceDataSource
-
getLeft
-
getRight
-
getRightPrefix
-
getCondition
-
getConditionAnalysis
-
getJoinType
-
getLeftFilter
-
getJoinableFactoryWrapper
-
getChildren
Description copied from interface:DataSourceReturns datasources that this datasource depends on. Will be empty for leaf datasources like 'table'.- Specified by:
getChildrenin interfaceDataSource
-
withChildren
Description copied from interface:DataSourceReturn 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.- Specified by:
withChildrenin interfaceDataSource
-
isCacheable
public boolean isCacheable(boolean isBroker) Description copied from interface:DataSourceReturns 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.- Specified by:
isCacheablein interfaceDataSource
-
isGlobal
public boolean isGlobal()Description copied from interface:DataSourceDecides if this datasource can be accessed globally.This means that all servers have a full copy of this datasource.
Examples: inline table, lookup.
- Specified by:
isGlobalin interfaceDataSource
-
isProcessable
public boolean isProcessable()Description copied from interface:DataSourceCommunicates that thisDataSourcecan be directly used to run aQuery.A Processable datasource must pack the necessary logic into the
DataSource.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.- Specified by:
isProcessablein interfaceDataSource
-
getVirtualColumnCandidates
Computes a set of column names for left table expressions in join condition which may already have been defined as a virtual column in the virtual column registry. It helps to remove any extraenous virtual columns created and only use the relevant ones.- Returns:
- a set of column names which might be virtual columns on left table in join condition
-
getCacheKey
public byte[] getCacheKey()Description copied from interface:DataSourceCompute 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- Specified by:
getCacheKeyin interfaceDataSource- Returns:
- the cache key to be used as part of query cache key
-
getJoinAlgorithm
-
equals
-
hashCode
public int hashCode() -
toString
-
createSegmentMapFunction
Creates a Function that maps base segments toHashJoinSegmentif needed (i.e. if the number of join clauses is > 0). If mapping is not needed, this method will returnFunction.identity().- Specified by:
createSegmentMapFunctionin interfaceDataSource- Parameters:
query-
-
createSegmentMapFunction
public static SegmentMapFunction createSegmentMapFunction(List<JoinableClause> clausesToUse, Filter baseFilterToUse, JoinFilterPreAnalysis joinFilterPreAnalysis, SegmentMapFunction baseMapFn) -
getJoinAnalysisForDataSource
Computes the DataSourceAnalysis with join boundaries. It will only process what the join datasource could handle in one go - and not more.
-