Class ExecutionVertex

java.lang.Object
org.apache.druid.query.planning.ExecutionVertex

public class ExecutionVertex extends Object
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 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 Details

    • topQuery

      protected final Query<?> topQuery
      The top level query this vertex is describing.
    • baseDataSource

      protected final DataSource baseDataSource
      The base datasource which will be read during the execution.
    • querySegmentSpec

      protected final QuerySegmentSpec querySegmentSpec
      The effective QuerySegmentSpec of this vertex - this might be more restrictive that what the Query has.
    • joinPrefixes

      protected final List<String> joinPrefixes
      Retained for compatibility with earlier implementation. See isBaseColumn(String)
    • allRightsAreGlobal

      protected boolean allRightsAreGlobal
      Retained for compatibility with earlier implementation.
  • Method Details

    • of

      public static ExecutionVertex of(Query<?> query)
      Identifies the vertex for the given query.
    • getBaseDataSource

      public DataSource 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.
    • ofDataSource

      public static ExecutionVertex ofDataSource(DataSource dataSource)
      Builds the ExecutionVertex around a DataSource. Kept for backward compatibility reasons - incorporating ExecutionVertex into Filtration will make this obsolete.
    • getBaseTableDataSource

      public final TableDataSource getBaseTableDataSource()
      Unwraps the getBaseDataSource() if its a TableDataSource.
      Throws:
      DruidException - error of type DruidException.Category.DEFENSIVE if the getBaseDataSource() is not a table. Note that this may not be true even isProcessable() ()} is true - in cases when the base datasource is a UnionDataSource of TableDataSource.
    • getEffectiveQuerySegmentSpec

      public QuerySegmentSpec getEffectiveQuerySegmentSpec()
      The applicable QuerySegmentSpec for 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.
    • isBaseColumn

      public boolean isBaseColumn(String columnName)
      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 a VirtualColumn to be coming from the base datasource.
      An alternate approach would be to analyze these during the segmentmap function creation.
    • buildQueryWithBaseDataSource

      public Query buildQueryWithBaseDataSource(DataSource newBaseDataSource)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • createSegmentMapFunction

      public SegmentMapFunction createSegmentMapFunction(PolicyEnforcer policyEnforcer)
      Assembles the segment mapping function which should be applied to the input segments.