Package org.apache.druid.query.planning
Class ExecutionVertex
java.lang.Object
org.apache.druid.query.planning.ExecutionVertex
Represents the native engine's execution vertex - the execution unit it may execute in one execution cycle.
An execution cycle is one call to either CachingClusteredClient or LocalQuerySegmentWalker.
This minimal Vertex a single
the GroupBy query could be collapsed at execution time. For example:
SELECT COUNT(*) FROM (SELECT string_first_added FROM druid.wikipedia_first_last GROUP BY 1) Will have 2 groupby queries; but they will be executed together - as that's suppoerted with
an execution may process a complex dag of datasources when
SELECT d3 FROM druid.numfoo, UNNEST(MV_TO_ARRAY(dim3)) as unnested (d3) inserts an UnnestDataSource into the query plan to execute the unnest operation. In case of a set of join-s: SELECT t1.dim1 FROM foo t1 JOIN foo t2 ON (t1.dim1=t2.dim2) JOIN foo t3 ON (t1.dim1=t3.dim2) There will be 2 JoinDataSource objects.
Query with an input DataSource.
However there might be more complicated cases.
Multiple queries could be executed in one stage: the GroupBy query could be collapsed at execution time. For example:
SELECT COUNT(*) FROM (SELECT string_first_added FROM druid.wikipedia_first_last GROUP BY 1) Will have 2 groupby queries; but they will be executed together - as that's suppoerted with
QueryToolChest.canPerformSubquery(Query).
There could be a DAG of datasources: an execution may process a complex dag of datasources when
JoinDataSource-es are present.
For example: SELECT d3 FROM druid.numfoo, UNNEST(MV_TO_ARRAY(dim3)) as unnested (d3) inserts an UnnestDataSource into the query plan to execute the unnest operation. In case of a set of join-s: SELECT t1.dim1 FROM foo t1 JOIN foo t2 ON (t1.dim1=t2.dim2) JOIN foo t3 ON (t1.dim1=t3.dim2) There will be 2 JoinDataSource objects.
Query
JoinDataSource - foo t3
JoinDataSource - foo t2
TableDataSource - foo t1
Which will be executed together - as the JoinDataSource-es are applied via segment mapping.
Every vertex has a base datasource - which could benefit from the advanced filtering techniques the cursors / walkers may provide.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanRetained for compatibility with earlier implementation.protected final DataSourceThe base datasource which will be read during the execution.Retained for compatibility with earlier implementation.protected final QuerySegmentSpecThe effectiveQuerySegmentSpecof this vertex - this might be more restrictive that what theQueryhas.protected final Query<?>The top level query this vertex is describing. -
Method Summary
Modifier and TypeMethodDescriptionbuildQueryWithBaseDataSource(DataSource newBaseDataSource) booleanDecides if the query can be executed using the cluster walker.booleanDecides if the query can be executed using the local walker.createSegmentMapFunction(PolicyEnforcer policyEnforcer) Assembles the segment mapping function which should be applied to the input segments.booleanThe base datasource input of this vertex.final TableDataSourceUnwraps thegetBaseDataSource()if its aTableDataSource.The applicableQuerySegmentSpecfor this vertex.inthashCode()booleanisBaseColumn(String columnName) Answers if the given column is coming from the base datasource or not.booleanDecides if this vertex is directly executable.booleanDecides if the execution time segment mapping function will be expensive.booleanThe vertex directly reads real tables.static ExecutionVertexIdentifies the vertex for the given query.static ExecutionVertexofDataSource(DataSource dataSource) Builds theExecutionVertexaround aDataSource.
-
Field Details
-
topQuery
The top level query this vertex is describing. -
baseDataSource
The base datasource which will be read during the execution. -
querySegmentSpec
The effectiveQuerySegmentSpecof this vertex - this might be more restrictive that what theQueryhas. -
joinPrefixes
Retained for compatibility with earlier implementation. SeeisBaseColumn(String) -
allRightsAreGlobal
protected boolean allRightsAreGlobalRetained for compatibility with earlier implementation.
-
-
Method Details
-
of
Identifies the vertex for the given query. -
ofDataSource
Builds theExecutionVertexaround aDataSource. Kept for backward compatibility reasons - incorporatingExecutionVertexinto Filtration will make this obsolete. -
getBaseDataSource
The base datasource input of this vertex. -
isProcessable
public boolean isProcessable()Decides if this vertex is directly executable. A vertex is directly executable if it can be executed without any further processing. See also:DataSource.isProcessable(). -
isTableBased
public boolean isTableBased()The vertex directly reads real tables. -
getBaseTableDataSource
Unwraps thegetBaseDataSource()if its aTableDataSource.- Throws:
DruidException- error of typeDruidException.Category.DEFENSIVEif thegetBaseDataSource()is not a table. Note that this may not be true evenisProcessable()()} is true - in cases when the base datasource is aUnionDataSourceofTableDataSource.
-
getEffectiveQuerySegmentSpec
The applicableQuerySegmentSpecfor this vertex. There might be more queries inside a single vertex; so the outer one is not necessary correct. -
canRunQueryUsingClusterWalker
public boolean canRunQueryUsingClusterWalker()Decides if the query can be executed using the cluster walker. -
canRunQueryUsingLocalWalker
public boolean canRunQueryUsingLocalWalker()Decides if the query can be executed using the local walker. -
isSegmentMapFunctionExpensive
public boolean isSegmentMapFunctionExpensive()Decides if the execution time segment mapping function will be expensive. -
getSegmentPruner
-
isBaseColumn
Answers if the given column is coming from the base datasource or not. Retained for backward compatibility for now. The approach taken here relies on join prefixes - which might classify the output of aVirtualColumnto be coming from the base datasource.
An alternate approach would be to analyze these during the segmentmap function creation. -
buildQueryWithBaseDataSource
-
createSegmentMapFunction
Assembles the segment mapping function which should be applied to the input segments. -
equals
-
hashCode
public int hashCode()
-