ResolveSubquery Logical Resolution Rule¶
ResolveSubquery is a logical resolution rule that resolves SubqueryExpressions in the following logical operators:
// Use Catalyst DSL import org.apache.spark.sql.catalyst.expressions._ val a = 'a.int import org.apache.spark.sql.catalyst.plans.logical.LocalRelation val rel = LocalRelation(a) import org.apache.spark.sql.catalyst.expressions.Literal val list = Seq[Literal](1) // FIXME Use a correct query to demo ResolveSubquery import org.apache.spark.sql.catalyst.plans.logical.Filter import org.apache.spark.sql.catalyst.expressions.In val plan = Filter(condition = In(value = a, list), child = rel) scala> println(plan.numberedTreeString) 00 Filter a#9 IN (1) 01 +- LocalRelation <empty>, [a#9] import spark.sessionState.analyzer.ResolveSubquery val analyzedPlan = ResolveSubquery(plan) scala> println(analyzedPlan.numberedTreeString) 00 Filter a#9 IN (1) 01 +- LocalRelation <empty>, [a#9]
apply( plan: LogicalPlan): LogicalPlan
apply resolves logical operators that have their children all resolved already.
apply is part of Rule abstraction.
resolveSubQueries( plan: LogicalPlan, plans: Seq[LogicalPlan]): LogicalPlan
resolveSubQueries is used when
ResolveSubquery is executed.
Resolving Subquery Plan¶
resolveSubQuery( e: SubqueryExpression, plans: Seq[LogicalPlan])( f: (LogicalPlan, Seq[Expression]) => SubqueryExpression): SubqueryExpression
In the end,
resolveSubQuery executes the given
f function with the logical plan (of the
SubqueryExpression) and all
OuterReference leaf expressions when the logical plan has been fully resolved. Otherwise,
resolveSubQuery requests the
SubqueryExpression to withNewPlan.
resolveSubQuery is used when
ResolveSubquery is requested to resolve subquery expressions.
Resolving Outer References (in Subquery Plan)¶
resolveOuterReferences( plan: LogicalPlan, outer: LogicalPlan): LogicalPlan
resolveOuterReferences translates resolved NamedExpression expressions to
OuterReference leaf expressions.
resolveOuterReferences is used when
ResolveSubquery is requested to resolve a SubqueryExpression.