Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
it actually works
  • Loading branch information
Robert Kruszewski committed Mar 29, 2018
commit 6b9c45d939112de8ef47f8f6ee34821275e53f96
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object PropagateEmptyRelation extends Rule[LogicalPlan] with PredicateHelper {

// Construct a project list from plan's output, while the value is always NULL.
private def nullValueProjectList(plan: LogicalPlan): Seq[NamedExpression] =
plan.output.map{ a => Alias(Cast(Literal(null), a.dataType), a.name)(a.exprId) }
plan.output.map{ a => Alias(Literal(null), a.name)(a.exprId) }

def apply(plan: LogicalPlan): LogicalPlan = plan transformUp {
case p: Union if p.children.forall(isEmptyLocalRelation) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.spark.sql.catalyst.optimizer

import org.apache.spark.sql.Row
import org.apache.spark.sql.catalyst.analysis.TypeCoercion
import org.apache.spark.sql.catalyst.{CatalystTypeConverters, InternalRow}
import org.apache.spark.sql.catalyst.dsl.expressions._
import org.apache.spark.sql.catalyst.dsl.plans._
Expand All @@ -37,7 +38,9 @@ class PropagateEmptyRelationSuite extends PlanTest {
ReplaceIntersectWithSemiJoin,
PushDownPredicate,
PruneFilters,
PropagateEmptyRelation) :: Nil
PropagateEmptyRelation,
CollapseProject,
TypeCoercion.FunctionArgumentConversion) :: Nil
}

object OptimizeWithoutPropagateEmptyRelation extends RuleExecutor[LogicalPlan] {
Expand Down Expand Up @@ -209,4 +212,11 @@ class PropagateEmptyRelationSuite extends PlanTest {

comparePlans(optimized, correctAnswer)
}

test("propaget empty relation keeps the plan resolved") {
val query = testRelation1.join(
LocalRelation('a.int, 'b.int), UsingJoin(FullOuter, "a" :: Nil), None)
val optimized = Optimize.execute(query.analyze)
assert(optimized.resolved)
}
}