RuleExecutors¶
RuleExecutor is an abstraction of rule executors that can execute batches of rules (that transform TreeNodes).
Contract¶
Batches of Rules¶
A sequence of batches of rules
Used when RuleExecutor is executed
Implementations¶
- Logical Adaptive Optimizer
- Logical Analyzer
ExpressionCanonicalizer- Logical Optimizers
Executing Batches of Rules¶
execute iterates over rule batches and applies rules sequentially to the input plan.
execute tracks the number of iterations and the time of executing each rule (with a plan).
When a rule changes a plan, you should see the following TRACE message in the logs:
After the number of iterations has reached the number of iterations for the batch's Strategy it stops execution and prints out the following WARN message to the logs:
When the plan has not changed (after applying rules), you should see the following TRACE message in the logs and execute moves on to applying the rules in the next batch. The moment is called fixed point (i.e. when the execution converges).
After the batch finishes, if the plan has been changed by the rules, you should see the following DEBUG message in the logs:
Otherwise, when the rules had no changes to a plan, you should see the following TRACE message in the logs:
Tracking Time of Executing Batches of Rules¶
executeAndTrack...FIXME
executeAndTrack is used when:
Analyzeris requested to executeAndCheckQueryExecutionis requested for the optimized logical plan
blacklistedOnceBatches¶
blacklistedOnceBatches is empty by default (Set.empty).
blacklistedOnceBatches is used when RuleExecutor is executed.
checkBatchIdempotence Internal Method¶
checkBatchIdempotence...FIXME
checkBatchIdempotence is used when RuleExecutor is executed.
isPlanIntegral¶
isPlanIntegral is true by default.
isPlanIntegral is used when RuleExecutor is executed.
Scala Definition¶
The definition of the RuleExecutor abstract class uses TreeType type parameter that is constrained by a upper type bound (TreeNode[_]). It says that TreeType type variable can only be a subtype of type TreeNode.
Tip
Read up on <: type operator in Scala in Upper Type Bounds.
Rule Batch — Collection of Rules¶
Batch is a named collection of rules with an execution strategy.
Batch is defined by the following:
- Batch Name
- Execution Strategy
- Collection of rules
Execution Strategy¶
Strategy is an abstraction of execution strategies.
maxIterations¶
Used when...FIXME
errorOnExceed¶
Used when...FIXME
maxIterationsSetting¶
Used when...FIXME
Implementations¶
FixedPoint¶
An execution strategy that runs until fix point (and converge) or maxIterations times, whichever comes first
Once¶
An execution strategy that runs only once (with maxIterations as 1)