SubqueryAlias Unary Logical Operator

SubqueryAlias is a unary logical operator that represents an aliased subquery (i.e. the child logical query plan with the alias in the output schema).

SubqueryAlias is created when:

SubqueryAlias simply requests the child logical operator for the canonicalized version.

When requested for output schema attributes, SubqueryAlias requests the child logical operator for them and adds the alias as a qualifier.

EliminateSubqueryAliases logical optimization eliminates (removes) SubqueryAlias operators from a logical query plan.
RewriteCorrelatedScalarSubquery logical optimization rewrites correlated scalar subqueries with SubqueryAlias operators.

Catalyst DSL — subquery And as Operators

as(alias: String): LogicalPlan
subquery(alias: Symbol): LogicalPlan

subquery and as operators in Catalyst DSL create a SubqueryAlias logical operator, e.g. for testing or Spark SQL internals exploration.

import org.apache.spark.sql.catalyst.dsl.plans._
val t1 = table("t1")

val plan = t1.subquery('a)
scala> println(plan.numberedTreeString)
00 'SubqueryAlias a
01 +- 'UnresolvedRelation `t1`

val plan ="a")
scala> println(plan.numberedTreeString)
00 'SubqueryAlias a
01 +- 'UnresolvedRelation `t1`

Creating SubqueryAlias Instance

SubqueryAlias takes the following when created:

results matching ""

    No results matching ""