public class DataSourceAnalysis extends Object
Q <-- Possible query datasource(s) [may be none, or multiple stacked]
|
Q <-- Base query datasource, returned by getBaseQuery() if it exists
|
J <-- Possible join tree, expected to be left-leaning
/ \
J Dj <-- Other leaf datasources
Base datasource / \ which will be joined
(bottom-leftmost) --> Db Dj <---- into the base datasource
The base datasource (Db) is returned by getBaseDataSource(). The other leaf datasources are returned by
getPreJoinableClauses(). The outer query datasources are available as part of getDataSource(),
which just returns the original datasource that was provided for analysis.
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 StorageAdapter. 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.| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
static DataSourceAnalysis |
forDataSource(DataSource dataSource) |
DataSource |
getBaseDataSource()
Returns the baseĀ (bottom-leftmost) datasource.
|
Optional<Query<?>> |
getBaseQuery()
Returns the bottommost (i.e.
|
Optional<QuerySegmentSpec> |
getBaseQuerySegmentSpec()
Returns the
QuerySegmentSpec that is associated with the base datasource, if any. |
Optional<TableDataSource> |
getBaseTableDataSource()
Returns the same datasource as
getBaseDataSource(), but only if it is a table. |
DataSource |
getDataSource()
Returns the topmost datasource: the original one passed to
forDataSource(DataSource). |
List<PreJoinableClause> |
getPreJoinableClauses()
Returns join clauses corresponding to joinable leaf datasources (every leaf except the bottom-leftmost).
|
int |
hashCode() |
boolean |
isConcreteBased()
Returns true if this datasource can be computed by the core Druid query stack via a scan of a concrete base
datasource.
|
boolean |
isConcreteTableBased()
Returns true if this datasource is concrete-based (see
isConcreteBased(), and the base datasource is a
'table' or union of them. |
boolean |
isGlobal()
Returns true if all servers have the ability to compute this datasource.
|
boolean |
isQuery()
Returns true if this datasource represents a subquery (that is, whether it is a
QueryDataSource). |
String |
toString() |
public static DataSourceAnalysis forDataSource(DataSource dataSource)
public DataSource getDataSource()
forDataSource(DataSource).public DataSource getBaseDataSource()
public Optional<TableDataSource> getBaseTableDataSource()
getBaseDataSource(), but only if it is a table. Useful on data servers,
since they generally can only handle queries where the base datasource is a table.public Optional<Query<?>> getBaseQuery()
Query from a possible stack of outer queries at the root of
the datasource tree. This is the query that will be applied to the base datasource plus any joinables that might
be present.isQuery() is true, else emptypublic Optional<QuerySegmentSpec> getBaseQuerySegmentSpec()
QuerySegmentSpec that is associated with the base datasource, if any. This only happens
when there is an outer query datasource. In this case, the base querySegmentSpec is the one associated with the
innermost subquery.
This QuerySegmentSpec is taken from the query returned by getBaseQuery().isQuery() is true, else emptypublic List<PreJoinableClause> getPreJoinableClauses()
public boolean isGlobal()
public boolean isConcreteBased()
public boolean isConcreteTableBased()
isConcreteBased(), and the base datasource is a
'table' or union of them. This is an important property because it corresponds to datasources that can be handled
by Druid data servers, like Historicals.public boolean isQuery()
QueryDataSource).Copyright © 2011–2020 The Apache Software Foundation. All rights reserved.