Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ abstract class PropagateEmptyRelationBase extends Rule[LogicalPlan] with CastSup
case Aggregate(ge, _, _) if ge.nonEmpty && !p.isStreaming => empty(p)
// Generators like Hive-style UDTF may return their records within `close`.
case Generate(_: Explode, _, _, _, _, _) => empty(p)
case Expand(_, _, _) => empty(p)
case _ => p
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.apache.spark.sql.catalyst.dsl.plans._
import org.apache.spark.sql.catalyst.expressions.Literal
import org.apache.spark.sql.catalyst.expressions.Literal.FalseLiteral
import org.apache.spark.sql.catalyst.plans._
import org.apache.spark.sql.catalyst.plans.logical.{LocalRelation, LogicalPlan, Project}
import org.apache.spark.sql.catalyst.plans.logical.{Expand, LocalRelation, LogicalPlan, Project}
import org.apache.spark.sql.catalyst.rules.RuleExecutor
import org.apache.spark.sql.types.{IntegerType, MetadataBuilder, StructType}

Expand Down Expand Up @@ -286,4 +286,12 @@ class PropagateEmptyRelationSuite extends PlanTest {
val optimized = Optimize.execute(query)
comparePlans(optimized, query)
}

test("SPARK-37689: Expand should be supported PropagateEmptyRelation") {
val query = Expand(Seq(Seq('a, 'b, "null"), Seq('a, "null", 'c)), Seq('a, 'b, 'c),
LocalRelation.fromExternalRows(Seq('a.int, 'b.int, 'c.int), Nil)).analyze
val optimized = Optimize.execute(query)
val expected = LocalRelation.fromExternalRows(Seq('a.int, 'b.int, 'c.int), Nil)
comparePlans(optimized, expected)
}
}