UpdateCTERelationStats Logical Optimization¶
UpdateCTERelationStats is a logical optimization that updateCTEStats for CTE logical operators.
UpdateCTERelationStats is part of the Update CTE Relation Stats once-executed batch in the standard batches of the Logical Optimizer.
UpdateCTERelationStats is simply a Catalyst rule for transforming logical plans (Rule[LogicalPlan]).
Executing Rule¶
apply(
plan: LogicalPlan): LogicalPlan
apply does nothing and simply returns the given LogicalPlan when applied to a Subquery or a non-CTE query plan. Otherwise, apply updateCTEStats.
apply is part of the Rule abstraction.
updateCTEStats¶
updateCTEStats(
plan: LogicalPlan,
statsMap: mutable.HashMap[Long, Statistics]): LogicalPlan
updateCTEStats branches off based on the type of the logical operator:
- WithCTE
- CTERelationRef
- Others with CTE tree pattern
For all other types, updateCTEStats returns the given LogicalPlan.
updateCTEStats is a recursive function.