Class

org.apache.spark.sql.catalyst.optimizer

StarSchemaDetection

Related Doc: package optimizer

Permalink

case class StarSchemaDetection(conf: SQLConf) extends PredicateHelper with Product with Serializable

Encapsulates star-schema detection logic.

Linear Supertypes
Serializable, Serializable, Product, Equals, PredicateHelper, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StarSchemaDetection
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. PredicateHelper
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new StarSchemaDetection(conf: SQLConf)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def canEvaluate(expr: Expression, plan: LogicalPlan): Boolean

    Permalink

    Returns true if expr can be evaluated using only the output of plan.

    Returns true if expr can be evaluated using only the output of plan. This method can be used to determine when it is acceptable to move expression evaluation within a query plan.

    For example consider a join between two relations R(a, b) and S(c, d).

    - canEvaluate(EqualTo(a,b), R) returns true - canEvaluate(EqualTo(a,c), R) returns false - canEvaluate(Literal(1), R) returns true as literals CAN be evaluated on any plan

    Attributes
    protected
    Definition Classes
    PredicateHelper
  6. def canEvaluateWithinJoin(expr: Expression): Boolean

    Permalink

    Returns true iff expr could be evaluated as a condition within join.

    Returns true iff expr could be evaluated as a condition within join.

    Attributes
    protected
    Definition Classes
    PredicateHelper
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. val conf: SQLConf

    Permalink
  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. def findStarJoins(input: Seq[LogicalPlan], conditions: Seq[Expression]): Seq[LogicalPlan]

    Permalink

    Star schema consists of one or more fact tables referencing a number of dimension tables.

    Star schema consists of one or more fact tables referencing a number of dimension tables. In general, star-schema joins are detected using the following conditions:

    1. Informational RI constraints (reliable detection) + Dimension contains a primary key that is being joined to the fact table. + Fact table contains foreign keys referencing multiple dimension tables. 2. Cardinality based heuristics + Usually, the table with the highest cardinality is the fact table. + Table being joined with the most number of tables is the fact table.

    To detect star joins, the algorithm uses a combination of the above two conditions. The fact table is chosen based on the cardinality heuristics, and the dimension tables are chosen based on the RI constraints. A star join will consist of the largest fact table joined with the dimension tables on their primary keys. To detect that a column is a primary key, the algorithm uses table and column statistics.

    The algorithm currently returns only the star join with the largest fact table. Choosing the largest fact table on the driving arm to avoid large inners is in general a good heuristic. This restriction will be lifted to observe multiple star joins.

    The highlights of the algorithm are the following:

    Given a set of joined tables/plans, the algorithm first verifies if they are eligible for star join detection. An eligible plan is a base table access with valid statistics. A base table access represents Project or Filter operators above a LeafNode. Conservatively, the algorithm only considers base table access as part of a star join since they provide reliable statistics. This restriction can be lifted with the CBO enablement by default.

    If some of the plans are not base table access, or statistics are not available, the algorithm returns an empty star join plan since, in the absence of statistics, it cannot make good planning decisions. Otherwise, the algorithm finds the table with the largest cardinality (number of rows), which is assumed to be a fact table.

    Next, it computes the set of dimension tables for the current fact table. A dimension table is assumed to be in a RI relationship with a fact table. To infer column uniqueness, the algorithm compares the number of distinct values with the total number of rows in the table. If their relative difference is within certain limits (i.e. ndvMaxError * 2, adjusted based on 1TB TPC-DS data), the column is assumed to be unique.

  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. def reorderStarJoins(input: Seq[(LogicalPlan, InnerLike)], conditions: Seq[Expression]): Seq[(LogicalPlan, InnerLike)]

    Permalink

    Reorders a star join based on heuristics.

    Reorders a star join based on heuristics. It is called from ReorderJoin if CBO is disabled. 1) Finds the star join with the largest fact table. 2) Places the fact table the driving arm of the left-deep tree. This plan avoids large table access on the inner, and thus favor hash joins. 3) Applies the most selective dimensions early in the plan to reduce the amount of data flow.

  18. def replaceAlias(condition: Expression, aliases: AttributeMap[Expression]): Expression

    Permalink
    Attributes
    protected
    Definition Classes
    PredicateHelper
  19. def splitConjunctivePredicates(condition: Expression): Seq[Expression]

    Permalink
    Attributes
    protected
    Definition Classes
    PredicateHelper
  20. def splitDisjunctivePredicates(condition: Expression): Seq[Expression]

    Permalink
    Attributes
    protected
    Definition Classes
    PredicateHelper
  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  22. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from PredicateHelper

Inherited from AnyRef

Inherited from Any

Ungrouped