CheckAnalysis — Analysis Validation
CheckAnalysis defines checkAnalysis method that Analyzer uses to check if a logical plan is correct (after all the transformations) by applying validation rules and in the end marking it as analyzed.
|
Note
|
An analyzed logical plan is correct and ready for execution. |
CheckAnalysis defines extendedCheckRules extension point that allows for extra analysis check rules.
Validating Analysis of Logical Plan (and Marking Plan As Analyzed) — checkAnalysis Method
|
1 2 3 4 5 |
checkAnalysis(plan: LogicalPlan): Unit |
checkAnalysis recursively checks the correctness of the analysis of the input logical plan and marks it as analyzed.
|
Note
|
checkAnalysis fails analysis when finds UnresolvedRelation in the input LogicalPlan…FIXME What else?
|
Internally, checkAnalysis processes nodes in the input plan (starting from the leafs, i.e. nodes down the operator tree).
checkAnalysis skips logical plans that have already undergo analysis.
| LogicalPlan/Operator | Behaviour | ||||
|---|---|---|---|---|---|
|
Fails analysis with the error message:
|
|||||
|
Unresolved Attribute |
Fails analysis with the error message:
|
||||
|
Fails analysis with the error message:
|
|||||
|
Unresolved |
Fails analysis with the error message:
|
||||
|
Fails analysis with the error message:
|
|||||
|
Fails analysis with the error message:
|
|||||
|
WindowExpressions with a AggregateExpression window function with isDistinct flag on |
Fails analysis with the error message:
Example:
|
||||
|
WindowExpressions with a OffsetWindowFunction window function with an empty order specification or a non-offset window frame specification |
Fails analysis with the error message:
|
||||
|
WindowExpressions with a window function that is not one of the following expressions: AggregateExpression, AggregateWindowFunction or OffsetWindowFunction |
Fails analysis with the error message:
|
||||
|
Nondeterministic expressions |
FIXME |
||||
|
FIXME |
|||||
|
FIXME |
FIXME |
After the validations, checkAnalysis executes additional check rules for correct analysis.
checkAnalysis then checks if plan is analyzed correctly (i.e. no logical plans are left unresolved). If there is one, checkAnalysis fails the analysis with AnalysisException and the following error message:
|
1 2 3 4 5 |
unresolved operator [o.simpleString] |
In the end, checkAnalysis marks the entire logical plan as analyzed.
|
Note
|
|
Extended Analysis Check Rules — extendedCheckRules Extension Point
|
1 2 3 4 5 |
extendedCheckRules: Seq[LogicalPlan => Unit] |
extendedCheckRules is a collection of rules (functions) that checkAnalysis uses for custom analysis checks (after the main validations have been executed).
|
Note
|
When a condition of a rule does not hold the function throws an AnalysisException directly or using failAnalysis method.
|
checkSubqueryExpression Internal Method
|
1 2 3 4 5 |
checkSubqueryExpression(plan: LogicalPlan, expr: SubqueryExpression): Unit |
checkSubqueryExpression…FIXME
|
Note
|
checkSubqueryExpression is used exclusively when CheckAnalysis is requested to validate analysis of a logical plan (for SubqueryExpression expressions).
|
spark技术分享