Skip to content

PhysicalOperation -- Scala Extractor for Destructuring Logical Query Plans

PhysicalOperation is a Scala extractor to <> into a tuple with the following elements:

. expressions/[Named expressions] (aka projects)

. expressions/[Expressions] (aka filters)

.[Logical operator] (aka leaf node)

[[ReturnType]] .ReturnType [source, scala]

(Seq[NamedExpression], Seq[Expression], LogicalPlan)

The following idiom is often used in Strategy implementations (e.g. hive/[HiveTableScans], InMemoryScans, DataSourceStrategy, <>):

[source, scala]

def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match { case PhysicalOperation(projections, predicates, plan) => // do something case _ => Nil }

Whenever used to pattern match to a LogicalPlan, PhysicalOperation's unapply is called.

=== [[unapply]] unapply Method

[source, scala]

type ReturnType = (Seq[NamedExpression], Seq[Expression], LogicalPlan)

unapply(plan: LogicalPlan): Option[ReturnType]


NOTE: unapply is almost <> method itself (with some manipulations of the return value).


unapply is used when...FIXME

Last update: 2021-02-18