ReplaceExpressions Logical Optimization¶
ReplaceExpressions
is a base logical optimization that <
ReplaceExpressions
is part of the Finish Analysis once-executed batch in the standard batches of the Logical Optimizer.
ReplaceExpressions
is simply a <Rule[LogicalPlan]
.
[source, scala]¶
val query = sql("select ifnull(NULL, array('2')) from values 1") val analyzedPlan = query.queryExecution.analyzed scala> println(analyzedPlan.numberedTreeString) 00 Project [ifnull(null, array(2)) AS ifnull(NULL, array('2'))#3] 01 +- LocalRelation [col1#2]
import org.apache.spark.sql.catalyst.optimizer.ReplaceExpressions val optimizedPlan = ReplaceExpressions(analyzedPlan) scala> println(optimizedPlan.numberedTreeString) 00 Project [coalesce(cast(null as array
=== [[apply]] Executing Rule -- apply
Method
[source, scala]¶
apply(plan: LogicalPlan): LogicalPlan¶
apply
<
apply
is part of the Rule abstraction.