Class JoinDataSourceAnalysis

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

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

  • Method Details

    • getBaseDataSource

      public DataSource getBaseDataSource()
      Returns the base (bottom-leftmost) datasource.
    • getJoinBaseTableFilter

      public Optional<DimFilter> 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

      public List<PreJoinableClause> getPreJoinableClauses()
      Returns join clauses corresponding to joinable leaf datasources (every leaf except the bottom-leftmost).
    • isBaseColumn

      public boolean isBaseColumn(String column)
      Returns whether "column" on the analyzed datasource refers to a column from the base datasource.
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • constructAnalysis

      public static JoinDataSourceAnalysis constructAnalysis(JoinDataSource dataSource)