Package org.apache.druid.query.planning
Class JoinDataSourceAnalysis
java.lang.Object
org.apache.druid.query.planning.JoinDataSourceAnalysis
Analysis of a datasource for purposes of deciding how to execute a particular query.
The analysis breaks a datasource down in the following way:
Q invalid input: '<'-- Possible query datasource(s) [may be none, or multiple stacked]
|
Q invalid input: '<'-- Base query datasource, returned by
invalid reference
#getBaseQuery()
if it exists
|
J invalid input: '<'-- Possible join tree, expected to be left-leaning
/ \
J Dj invalid input: '<'-- Other leaf datasources
Base datasource / \ which will be joined
(bottom-leftmost) --> Db Dj invalid input: '<'---- into the base datasource
The base datasource (Db) is returned by getBaseDataSource(). The other leaf datasources are returned by
getPreJoinableClauses().
The base datasource (Db) will never be a join, but it can be any other type of datasource (table, query, etc).
Note that join trees are only flattened if they occur at the top of the overall tree (or underneath an outer query),
and that join trees are only flattened to the degree that they are left-leaning. Due to these facts, it is possible
for the base or leaf datasources to include additional joins.
The base datasource is the one that will be considered by the core Druid query stack for scanning via
Segment and CursorFactory. The other leaf
datasources must be joinable onto the base data.
The idea here is to keep things simple and dumb. So we focus only on identifying left-leaning join trees, which map
neatly onto a series of hash table lookups at query time. The user/system generating the queries, e.g. the druid-sql
layer (or the end user in the case of native queries), is responsible for containing the smarts to structure the
tree in a way that will lead to optimal execution.-
Constructor Summary
ConstructorsConstructorDescriptionJoinDataSourceAnalysis(DataSource baseDataSource, Query<?> baseQuery, DimFilter joinBaseTableFilter, List<PreJoinableClause> preJoinableClauses, QuerySegmentSpec querySegmentSpec) -
Method Summary
Modifier and TypeMethodDescriptionstatic JoinDataSourceAnalysisconstructAnalysis(JoinDataSource dataSource) booleanReturns the base (bottom-leftmost) datasource.If the original data source is a join data source and there is a DimFilter on the base table data source, that DimFilter is returned hereReturns join clauses corresponding to joinable leaf datasources (every leaf except the bottom-leftmost).inthashCode()booleanisBaseColumn(String column) Returns whether "column" on the analyzed datasource refers to a column from the base datasource.toString()
-
Constructor Details
-
JoinDataSourceAnalysis
public JoinDataSourceAnalysis(DataSource baseDataSource, @Nullable Query<?> baseQuery, @Nullable DimFilter joinBaseTableFilter, List<PreJoinableClause> preJoinableClauses, @Nullable QuerySegmentSpec querySegmentSpec)
-
-
Method Details
-
getBaseDataSource
Returns the base (bottom-leftmost) datasource. -
getJoinBaseTableFilter
If the original data source is a join data source and there is a DimFilter on the base table data source, that DimFilter is returned here -
getPreJoinableClauses
Returns join clauses corresponding to joinable leaf datasources (every leaf except the bottom-leftmost). -
isBaseColumn
Returns whether "column" on the analyzed datasource refers to a column from the base datasource. -
equals
-
hashCode
public int hashCode() -
toString
-
constructAnalysis
-