public class JoinDataSource extends Object implements 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 DataSourceAnalysis, the right-hand side of this datasource
will become a PreJoinableClause object.
| Modifier and Type | Method and Description |
|---|---|
static JoinDataSource |
create(DataSource left,
DataSource right,
String rightPrefix,
JoinConditionAnalysis conditionAnalysis,
JoinType joinType,
DimFilter leftFilter,
JoinableFactoryWrapper joinableFactoryWrapper)
Create a join dataSource from an existing
JoinConditionAnalysis. |
static JoinDataSource |
create(DataSource left,
DataSource right,
String rightPrefix,
String condition,
JoinType joinType,
DimFilter leftFilter,
ExprMacroTable macroTable,
JoinableFactoryWrapper joinableFactoryWrapper)
Create a join dataSource from a string condition.
|
Function<SegmentReference,SegmentReference> |
createSegmentMapFn(Filter baseFilter,
List<PreJoinableClause> clauses,
AtomicLong cpuTimeAccumulator,
Query<?> query)
Creates a Function that maps base segments to
HashJoinSegment if needed (i.e. |
Function<SegmentReference,SegmentReference> |
createSegmentMapFunction(Query query,
AtomicLong cpuTimeAccumulator)
Returns a segment function on to how to segment should be modified.
|
boolean |
equals(Object o) |
byte[] |
getCacheKey()
Compute a cache key prefix for a data source.
|
List<DataSource> |
getChildren()
Returns datasources that this datasource depends on.
|
String |
getCondition() |
JoinConditionAnalysis |
getConditionAnalysis() |
JoinableFactoryWrapper |
getJoinableFactoryWrapper() |
JoinType |
getJoinType() |
DataSource |
getLeft() |
DimFilter |
getLeftFilter() |
DataSource |
getRight() |
String |
getRightPrefix() |
Set<String> |
getTableNames()
Returns the names of all table datasources involved in this query.
|
Set<String> |
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.
|
int |
hashCode() |
boolean |
isCacheable(boolean isBroker)
Returns true if queries on this dataSource are cacheable at both the result level and per-segment level.
|
boolean |
isConcrete()
Returns true if this datasource represents concrete data that can be scanned via a
Segment adapter of some kind. |
boolean |
isGlobal()
Returns true if all servers have a full copy of this datasource.
|
String |
toString() |
DataSource |
withChildren(List<DataSource> children)
Return a new DataSource, identical to this one, with different children.
|
DataSource |
withUpdatedDataSource(DataSource newSource)
Returns an updated datasource based on the specified new source.
|
public static JoinDataSource create(DataSource left, DataSource right, String rightPrefix, String condition, JoinType joinType, @Nullable DimFilter leftFilter, ExprMacroTable macroTable, @Nullable JoinableFactoryWrapper joinableFactoryWrapper)
public static JoinDataSource create(DataSource left, DataSource right, String rightPrefix, JoinConditionAnalysis conditionAnalysis, JoinType joinType, DimFilter leftFilter, @Nullable JoinableFactoryWrapper joinableFactoryWrapper)
JoinConditionAnalysis.public Set<String> getTableNames()
DataSourcegetTableNames in interface DataSourcepublic DataSource getLeft()
public DataSource getRight()
public String getRightPrefix()
public String getCondition()
public JoinConditionAnalysis getConditionAnalysis()
public JoinType getJoinType()
@Nullable public JoinableFactoryWrapper getJoinableFactoryWrapper()
public List<DataSource> getChildren()
DataSourcegetChildren in interface DataSourcepublic DataSource withChildren(List<DataSource> children)
DataSourcewithChildren in interface DataSourcepublic boolean isCacheable(boolean isBroker)
DataSourceisCacheable in interface DataSourcepublic boolean isGlobal()
DataSourceJoinableFactory which might build a
Joinable for this datasource directly. If a subquery 'inline' join is
required to join this datasource on the right hand side, then this value must be false for now.
In the future, instead of directly using this method, the query planner and engine should consider
JoinableFactory.isDirectlyJoinable(DataSource) when determining if the
right hand side is directly joinable, which would allow decoupling this property from joins.isGlobal in interface DataSourcepublic boolean isConcrete()
DataSourceSegment adapter of some kind. True for e.g. 'table' but not for 'query' or 'join'.isConcrete in interface DataSourcewhich uses this,
which uses thispublic Set<String> getVirtualColumnCandidates()
public Function<SegmentReference,SegmentReference> createSegmentMapFn(@Nullable Filter baseFilter, List<PreJoinableClause> clauses, AtomicLong cpuTimeAccumulator, Query<?> query)
HashJoinSegment if needed (i.e. if the number of join
clauses is > 0). If mapping is not needed, this method will return Function.identity().baseFilter - Filter to apply before the join takes placeclauses - Pre-joinable clausescpuTimeAccumulator - An accumulator that we will add CPU nanos to; this is part of the function to encourage
callers to remember to track metrics on CPU time required for creation of Joinablesquery - The query that will be run on the mapped segments. Usually this should be
analysis.getBaseQuery().orElse(query), where "analysis" is a
DataSourceAnalysis and "query" is the original
query from the end user.public Function<SegmentReference,SegmentReference> createSegmentMapFunction(Query query, AtomicLong cpuTimeAccumulator)
DataSourcecreateSegmentMapFunction in interface DataSourcequery - the input querycpuTimeAccumulator - the cpu time accumulatorpublic DataSource withUpdatedDataSource(DataSource newSource)
DataSourcewithUpdatedDataSource in interface DataSourcenewSource - the new datasource to be used to update an existing querypublic byte[] getCacheKey()
DataSourcePreJoinableClause
- 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.getCacheKey in interface DataSourceCopyright © 2011–2022 The Apache Software Foundation. All rights reserved.