viirya commented on code in PR #60538:
URL: https://github.com/apache/spark/pull/60538#discussion_r4581451716
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala:
##########
@@ -904,6 +907,179 @@ class WholeStageCodegenSuite extends SharedSparkSession
}
}
+ test("SPARK-61761: Whole-stage codegen stages do not serialize plan nodes
into tasks") {
+ // The RDD that a codegen stage adds on top of its input RDDs is
serialized into every task
+ // binary, so it must not hold a plan node (see `serializedPlanNodes`).
This checks every
+ // codegen stage of queries that cover the operators that generate code,
through adaptive query
+ // stages and subqueries.
+ val noBroadcast = Seq(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1")
+ val forceShj = noBroadcast :+ ("spark.sql.join.forceApplyShuffledHashJoin"
-> "true")
+ val sortAgg =
+ Seq(SQLConf.USE_HASH_AGG.key -> "false", SQLConf.USE_OBJECT_HASH_AGG.key
-> "false")
+ // (name, configs, the query, the names of nodes that must be generated,
by prefix)
+ def cases: Seq[(String, Seq[(String, String)], () => DataFrame,
Set[String])] = {
+ def l = spark.table("l")
+ def r = spark.table("r")
+ def join(strategy: String, joinType: String, buildLeft: Boolean =
false): () => DataFrame =
+ () => {
+ val cond = $"k1" === $"k2" && $"v1" =!= $"v2"
+ if (buildLeft) l.hint(strategy).join(r, cond, joinType)
+ else l.join(r.hint(strategy), cond, joinType)
+ }
+ val existenceJoin = "SELECT * FROM l WHERE EXISTS (SELECT 1 FROM r WHERE
k2 = k1) OR v1 < 3"
+ val aggs = Seq(
+ ("hash aggregate", Nil, () => l.groupBy("k1").agg(sum("v1"),
avg("v1")),
+ Set("HashAggregate")),
+ ("hash aggregate, row-based fast hash map",
+ Seq(SQLConf.ENABLE_TWOLEVEL_AGG_MAP.key -> "true",
+ SQLConf.ENABLE_VECTORIZED_HASH_MAP.key -> "false"),
+ () => l.groupBy("k1").agg(sum("v1")), Set("HashAggregate")),
+ ("hash aggregate, vectorized fast hash map",
+ Seq(SQLConf.ENABLE_TWOLEVEL_AGG_MAP.key -> "true",
+ SQLConf.ENABLE_VECTORIZED_HASH_MAP.key -> "true"),
+ () => l.groupBy("k1").agg(sum("v1")), Set("HashAggregate")),
+ ("hash aggregate, adaptive partial aggregation",
+ Seq(SQLConf.ADAPTIVE_PARTIAL_AGGREGATION_ENABLED.key -> "true"),
+ () => l.groupBy("k1").agg(sum("v1")), Set("HashAggregate")),
+ ("hash aggregate without grouping keys", Nil, () => l.agg(sum("v1"),
max("k1")),
+ Set("HashAggregate")),
+ ("distinct aggregate", Nil, () =>
l.groupBy("k1").agg(countDistinct("v1"), sum("v1")),
+ Set("HashAggregate")),
+ ("aggregate with a filter", Nil,
+ () => sql("SELECT k1, sum(v1) FILTER (WHERE v1 > 10) FROM l GROUP BY
k1"),
+ Set("HashAggregate")),
+ ("sort aggregate", sortAgg, () => l.groupBy("k1").agg(sum("v1"),
max("v1")),
+ Set("SortAggregate")),
+ ("sort aggregate without grouping keys", sortAgg, () =>
l.agg(sum("v1"), max("v1")),
+ Set("SortAggregate")))
+ val joinTypes =
+ Seq("inner", "left_outer", "right_outer", "full_outer", "left_semi",
"left_anti")
+ val smj = joinTypes.map { joinType =>
+ (s"sort merge join, $joinType", noBroadcast, join("SHUFFLE_MERGE",
joinType),
+ Set("Sort", "SortMergeJoin"))
+ } :+ ("sort merge join, existence", noBroadcast, () =>
sql(existenceJoin),
+ Set("SortMergeJoin"))
+ val shj = joinTypes.flatMap { joinType =>
+ Seq(false, true).filter(buildLeft => joinType match {
+ case "left_semi" | "left_anti" => !buildLeft
+ case _ => true
+ }).map { buildLeft =>
+ (s"shuffled hash join, $joinType, build ${if (buildLeft) "left" else
"right"}",
+ noBroadcast, join("SHUFFLE_HASH", joinType, buildLeft),
Set("ShuffledHashJoin"))
+ }
+ } :+ ("shuffled hash join, existence", forceShj, () =>
sql(existenceJoin),
+ Set("ShuffledHashJoin"))
+ val bhj = Seq(("inner", false), ("inner", true), ("left_outer", false),
+ ("right_outer", true), ("left_semi", false), ("left_anti",
false)).map {
+ case (joinType, buildLeft) =>
+ (s"broadcast hash join, $joinType, build ${if (buildLeft) "left"
else "right"}",
+ noBroadcast, join("BROADCAST", joinType, buildLeft),
Set("BroadcastHashJoin"))
+ } :+ ("broadcast hash join, existence", Nil, () => sql(existenceJoin),
+ Set("BroadcastHashJoin"))
+ val bnlj = Seq("inner", "left_outer", "left_semi", "left_anti").map {
joinType =>
+ (s"broadcast nested loop join, $joinType", noBroadcast,
+ () => l.join(broadcast(r), $"k1" < $"k2" || $"v1" === $"v2",
joinType),
+ Set("BroadcastNestedLoopJoin"))
+ }
+ val rangeJoin = Seq("inner", "left_outer", "left_semi").map { joinType =>
+ (s"broadcast range join, $joinType",
+ noBroadcast :+ (SQLConf.BROADCAST_RANGE_JOIN_ENABLED.key -> "true"),
+ () => l.join(broadcast(r), $"v1" >= $"k2" && $"v1" <= $"v2",
joinType),
+ Set("BroadcastRangeJoin"))
+ }
+ val asOfJoin = Seq(("as-of join", noBroadcast :+
+ (SQLConf.SORT_MERGE_AS_OF_JOIN_ENABLED.key -> "true"),
+ () => {
+ val right = r.withColumnRenamed("k2", "k1")
+ l.joinAsOf(right, l("v1"), right("v2"), usingColumns = Seq("k1"),
joinType = "inner",
+ tolerance = null, allowExactMatches = true, direction = "backward")
+ },
+ Set("SortMergeAsOfJoin")))
+ val others = Seq(
+ ("sort", Nil, () => l.orderBy($"v1".desc), Set("Sort")),
+ ("expand", Nil, () => l.rollup("k1").agg(sum("v1")), Set("Expand")),
+ ("generate", Nil, () => l.select($"k1", explode(array($"v1", $"v1" +
1))),
+ Set("Generate")),
+ ("window", Nil,
Review Comment:
Dropped, and window is no longer listed in the PR description.
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala:
##########
@@ -827,16 +836,10 @@ class WholeStageCodegenSuite extends SharedSparkSession
checkAnswer(result, expected)
// The RDDs are cached by the plans, so these are the ones the query
ran.
val plan = result.queryExecution.executedPlan
- // All the nodes of the plan, including those in adaptive query
stages.
- def allNodes(p: SparkPlan): Seq[SparkPlan] = p +: (p match {
- case a: AdaptiveSparkPlanExec => allNodes(a.executedPlan)
- case q: QueryStageExec => allNodes(q.plan)
- case other => other.children.flatMap(allNodes)
- })
- val nodes = allNodes(plan)
+ val nodes = allPlanNodes(plan)
Review Comment:
Added to the PR description.
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala:
##########
@@ -904,6 +907,179 @@ class WholeStageCodegenSuite extends SharedSparkSession
}
}
+ test("SPARK-61761: Whole-stage codegen stages do not serialize plan nodes
into tasks") {
+ // The RDD that a codegen stage adds on top of its input RDDs is
serialized into every task
+ // binary, so it must not hold a plan node (see `serializedPlanNodes`).
This checks every
+ // codegen stage of queries that cover the operators that generate code,
through adaptive query
+ // stages and subqueries.
+ val noBroadcast = Seq(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1")
+ val forceShj = noBroadcast :+ ("spark.sql.join.forceApplyShuffledHashJoin"
-> "true")
+ val sortAgg =
+ Seq(SQLConf.USE_HASH_AGG.key -> "false", SQLConf.USE_OBJECT_HASH_AGG.key
-> "false")
+ // (name, configs, the query, the names of nodes that must be generated,
by prefix)
+ def cases: Seq[(String, Seq[(String, String)], () => DataFrame,
Set[String])] = {
+ def l = spark.table("l")
+ def r = spark.table("r")
+ def join(strategy: String, joinType: String, buildLeft: Boolean =
false): () => DataFrame =
+ () => {
+ val cond = $"k1" === $"k2" && $"v1" =!= $"v2"
+ if (buildLeft) l.hint(strategy).join(r, cond, joinType)
+ else l.join(r.hint(strategy), cond, joinType)
+ }
+ val existenceJoin = "SELECT * FROM l WHERE EXISTS (SELECT 1 FROM r WHERE
k2 = k1) OR v1 < 3"
+ val aggs = Seq(
+ ("hash aggregate", Nil, () => l.groupBy("k1").agg(sum("v1"),
avg("v1")),
+ Set("HashAggregate")),
+ ("hash aggregate, row-based fast hash map",
+ Seq(SQLConf.ENABLE_TWOLEVEL_AGG_MAP.key -> "true",
+ SQLConf.ENABLE_VECTORIZED_HASH_MAP.key -> "false"),
+ () => l.groupBy("k1").agg(sum("v1")), Set("HashAggregate")),
+ ("hash aggregate, vectorized fast hash map",
+ Seq(SQLConf.ENABLE_TWOLEVEL_AGG_MAP.key -> "true",
+ SQLConf.ENABLE_VECTORIZED_HASH_MAP.key -> "true"),
+ () => l.groupBy("k1").agg(sum("v1")), Set("HashAggregate")),
+ ("hash aggregate, adaptive partial aggregation",
+ Seq(SQLConf.ADAPTIVE_PARTIAL_AGGREGATION_ENABLED.key -> "true"),
+ () => l.groupBy("k1").agg(sum("v1")), Set("HashAggregate")),
+ ("hash aggregate without grouping keys", Nil, () => l.agg(sum("v1"),
max("k1")),
+ Set("HashAggregate")),
+ ("distinct aggregate", Nil, () =>
l.groupBy("k1").agg(countDistinct("v1"), sum("v1")),
+ Set("HashAggregate")),
+ ("aggregate with a filter", Nil,
+ () => sql("SELECT k1, sum(v1) FILTER (WHERE v1 > 10) FROM l GROUP BY
k1"),
+ Set("HashAggregate")),
+ ("sort aggregate", sortAgg, () => l.groupBy("k1").agg(sum("v1"),
max("v1")),
+ Set("SortAggregate")),
+ ("sort aggregate without grouping keys", sortAgg, () =>
l.agg(sum("v1"), max("v1")),
+ Set("SortAggregate")))
+ val joinTypes =
+ Seq("inner", "left_outer", "right_outer", "full_outer", "left_semi",
"left_anti")
+ val smj = joinTypes.map { joinType =>
+ (s"sort merge join, $joinType", noBroadcast, join("SHUFFLE_MERGE",
joinType),
+ Set("Sort", "SortMergeJoin"))
+ } :+ ("sort merge join, existence", noBroadcast, () =>
sql(existenceJoin),
+ Set("SortMergeJoin"))
+ val shj = joinTypes.flatMap { joinType =>
+ Seq(false, true).filter(buildLeft => joinType match {
+ case "left_semi" | "left_anti" => !buildLeft
+ case _ => true
+ }).map { buildLeft =>
+ (s"shuffled hash join, $joinType, build ${if (buildLeft) "left" else
"right"}",
+ noBroadcast, join("SHUFFLE_HASH", joinType, buildLeft),
Set("ShuffledHashJoin"))
+ }
+ } :+ ("shuffled hash join, existence", forceShj, () =>
sql(existenceJoin),
+ Set("ShuffledHashJoin"))
+ val bhj = Seq(("inner", false), ("inner", true), ("left_outer", false),
+ ("right_outer", true), ("left_semi", false), ("left_anti",
false)).map {
+ case (joinType, buildLeft) =>
+ (s"broadcast hash join, $joinType, build ${if (buildLeft) "left"
else "right"}",
+ noBroadcast, join("BROADCAST", joinType, buildLeft),
Set("BroadcastHashJoin"))
+ } :+ ("broadcast hash join, existence", Nil, () => sql(existenceJoin),
+ Set("BroadcastHashJoin"))
+ val bnlj = Seq("inner", "left_outer", "left_semi", "left_anti").map {
joinType =>
+ (s"broadcast nested loop join, $joinType", noBroadcast,
+ () => l.join(broadcast(r), $"k1" < $"k2" || $"v1" === $"v2",
joinType),
+ Set("BroadcastNestedLoopJoin"))
+ }
+ val rangeJoin = Seq("inner", "left_outer", "left_semi").map { joinType =>
+ (s"broadcast range join, $joinType",
+ noBroadcast :+ (SQLConf.BROADCAST_RANGE_JOIN_ENABLED.key -> "true"),
+ () => l.join(broadcast(r), $"v1" >= $"k2" && $"v1" <= $"v2",
joinType),
+ Set("BroadcastRangeJoin"))
+ }
+ val asOfJoin = Seq(("as-of join", noBroadcast :+
+ (SQLConf.SORT_MERGE_AS_OF_JOIN_ENABLED.key -> "true"),
+ () => {
+ val right = r.withColumnRenamed("k2", "k1")
+ l.joinAsOf(right, l("v1"), right("v2"), usingColumns = Seq("k1"),
joinType = "inner",
+ tolerance = null, allowExactMatches = true, direction = "backward")
+ },
+ Set("SortMergeAsOfJoin")))
+ val others = Seq(
+ ("sort", Nil, () => l.orderBy($"v1".desc), Set("Sort")),
+ ("expand", Nil, () => l.rollup("k1").agg(sum("v1")), Set("Expand")),
+ ("generate", Nil, () => l.select($"k1", explode(array($"v1", $"v1" +
1))),
+ Set("Generate")),
+ ("window", Nil,
+ () => l.select($"k1",
rank().over(Window.partitionBy("k1").orderBy("v1"))),
+ Set("Sort")),
+ ("limit", Nil, () => l.limit(5).groupBy("k1").count(),
Set("GlobalLimit")),
+ ("sample", Nil, () => l.sample(0.5, 1L), Set("Sample")),
+ ("union", Nil, () =>
l.select("k1").union(r.select("k2")).groupBy("k1").count(),
+ Set("Union")),
+ ("objects", Nil, () => spark.range(10).as[Long].map(_ * 2).filter(_ >
3).toDF(),
+ Set("MapElements")),
+ ("scalar and IN subqueries", noBroadcast, () => sql(
+ "SELECT k1, (SELECT max(v2) FROM r WHERE v2 < 5) FROM l " +
+ "WHERE k1 IN (SELECT k2 FROM r WHERE v2 > 3)"),
+ Set("Project")),
+ ("vectorized parquet scan", Nil, () => spark.table("p").where($"v1" >
3)
+ .groupBy("k1").count(), Set("ColumnarToRow")),
+ ("row-based parquet scan",
Seq(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> "false"),
+ () => spark.table("p").where($"v1" > 3).groupBy("k1").count(),
Set("Filter")),
+ ("cached table scan", Nil, () =>
spark.table("c").groupBy("k1").count(),
+ Set("HashAggregate", "Range")),
+ ("merge rows", Nil, () => {
+ val source = l.selectExpr("CAST(v1 AS INT) AS t", "CAST(k1 AS INT)
AS s")
+ val attrs = source.queryExecution.analyzed.output
+ classic.Dataset.ofRows(spark, MergeRows(
Review Comment:
Done. `mergeRows(source: DataFrame)` is now shared with the SPARK-60403 test.
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala:
##########
@@ -904,6 +907,179 @@ class WholeStageCodegenSuite extends SharedSparkSession
}
}
+ test("SPARK-61761: Whole-stage codegen stages do not serialize plan nodes
into tasks") {
+ // The RDD that a codegen stage adds on top of its input RDDs is
serialized into every task
+ // binary, so it must not hold a plan node (see `serializedPlanNodes`).
This checks every
+ // codegen stage of queries that cover the operators that generate code,
through adaptive query
+ // stages and subqueries.
+ val noBroadcast = Seq(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1")
+ val forceShj = noBroadcast :+ ("spark.sql.join.forceApplyShuffledHashJoin"
-> "true")
+ val sortAgg =
+ Seq(SQLConf.USE_HASH_AGG.key -> "false", SQLConf.USE_OBJECT_HASH_AGG.key
-> "false")
+ // (name, configs, the query, the names of nodes that must be generated,
by prefix)
+ def cases: Seq[(String, Seq[(String, String)], () => DataFrame,
Set[String])] = {
+ def l = spark.table("l")
+ def r = spark.table("r")
+ def join(strategy: String, joinType: String, buildLeft: Boolean =
false): () => DataFrame =
+ () => {
+ val cond = $"k1" === $"k2" && $"v1" =!= $"v2"
+ if (buildLeft) l.hint(strategy).join(r, cond, joinType)
+ else l.join(r.hint(strategy), cond, joinType)
+ }
+ val existenceJoin = "SELECT * FROM l WHERE EXISTS (SELECT 1 FROM r WHERE
k2 = k1) OR v1 < 3"
+ val aggs = Seq(
+ ("hash aggregate", Nil, () => l.groupBy("k1").agg(sum("v1"),
avg("v1")),
+ Set("HashAggregate")),
+ ("hash aggregate, row-based fast hash map",
+ Seq(SQLConf.ENABLE_TWOLEVEL_AGG_MAP.key -> "true",
+ SQLConf.ENABLE_VECTORIZED_HASH_MAP.key -> "false"),
+ () => l.groupBy("k1").agg(sum("v1")), Set("HashAggregate")),
+ ("hash aggregate, vectorized fast hash map",
+ Seq(SQLConf.ENABLE_TWOLEVEL_AGG_MAP.key -> "true",
+ SQLConf.ENABLE_VECTORIZED_HASH_MAP.key -> "true"),
+ () => l.groupBy("k1").agg(sum("v1")), Set("HashAggregate")),
+ ("hash aggregate, adaptive partial aggregation",
+ Seq(SQLConf.ADAPTIVE_PARTIAL_AGGREGATION_ENABLED.key -> "true"),
+ () => l.groupBy("k1").agg(sum("v1")), Set("HashAggregate")),
+ ("hash aggregate without grouping keys", Nil, () => l.agg(sum("v1"),
max("k1")),
+ Set("HashAggregate")),
+ ("distinct aggregate", Nil, () =>
l.groupBy("k1").agg(countDistinct("v1"), sum("v1")),
+ Set("HashAggregate")),
+ ("aggregate with a filter", Nil,
+ () => sql("SELECT k1, sum(v1) FILTER (WHERE v1 > 10) FROM l GROUP BY
k1"),
+ Set("HashAggregate")),
+ ("sort aggregate", sortAgg, () => l.groupBy("k1").agg(sum("v1"),
max("v1")),
+ Set("SortAggregate")),
+ ("sort aggregate without grouping keys", sortAgg, () =>
l.agg(sum("v1"), max("v1")),
+ Set("SortAggregate")))
+ val joinTypes =
+ Seq("inner", "left_outer", "right_outer", "full_outer", "left_semi",
"left_anti")
+ val smj = joinTypes.map { joinType =>
+ (s"sort merge join, $joinType", noBroadcast, join("SHUFFLE_MERGE",
joinType),
+ Set("Sort", "SortMergeJoin"))
+ } :+ ("sort merge join, existence", noBroadcast, () =>
sql(existenceJoin),
+ Set("SortMergeJoin"))
+ val shj = joinTypes.flatMap { joinType =>
+ Seq(false, true).filter(buildLeft => joinType match {
+ case "left_semi" | "left_anti" => !buildLeft
+ case _ => true
+ }).map { buildLeft =>
+ (s"shuffled hash join, $joinType, build ${if (buildLeft) "left" else
"right"}",
+ noBroadcast, join("SHUFFLE_HASH", joinType, buildLeft),
Set("ShuffledHashJoin"))
+ }
+ } :+ ("shuffled hash join, existence", forceShj, () =>
sql(existenceJoin),
+ Set("ShuffledHashJoin"))
+ val bhj = Seq(("inner", false), ("inner", true), ("left_outer", false),
+ ("right_outer", true), ("left_semi", false), ("left_anti",
false)).map {
+ case (joinType, buildLeft) =>
+ (s"broadcast hash join, $joinType, build ${if (buildLeft) "left"
else "right"}",
+ noBroadcast, join("BROADCAST", joinType, buildLeft),
Set("BroadcastHashJoin"))
+ } :+ ("broadcast hash join, existence", Nil, () => sql(existenceJoin),
+ Set("BroadcastHashJoin"))
+ val bnlj = Seq("inner", "left_outer", "left_semi", "left_anti").map {
joinType =>
+ (s"broadcast nested loop join, $joinType", noBroadcast,
+ () => l.join(broadcast(r), $"k1" < $"k2" || $"v1" === $"v2",
joinType),
+ Set("BroadcastNestedLoopJoin"))
+ }
+ val rangeJoin = Seq("inner", "left_outer", "left_semi").map { joinType =>
+ (s"broadcast range join, $joinType",
+ noBroadcast :+ (SQLConf.BROADCAST_RANGE_JOIN_ENABLED.key -> "true"),
+ () => l.join(broadcast(r), $"v1" >= $"k2" && $"v1" <= $"v2",
joinType),
+ Set("BroadcastRangeJoin"))
+ }
+ val asOfJoin = Seq(("as-of join", noBroadcast :+
+ (SQLConf.SORT_MERGE_AS_OF_JOIN_ENABLED.key -> "true"),
+ () => {
+ val right = r.withColumnRenamed("k2", "k1")
+ l.joinAsOf(right, l("v1"), right("v2"), usingColumns = Seq("k1"),
joinType = "inner",
+ tolerance = null, allowExactMatches = true, direction = "backward")
+ },
+ Set("SortMergeAsOfJoin")))
+ val others = Seq(
+ ("sort", Nil, () => l.orderBy($"v1".desc), Set("Sort")),
+ ("expand", Nil, () => l.rollup("k1").agg(sum("v1")), Set("Expand")),
+ ("generate", Nil, () => l.select($"k1", explode(array($"v1", $"v1" +
1))),
+ Set("Generate")),
+ ("window", Nil,
+ () => l.select($"k1",
rank().over(Window.partitionBy("k1").orderBy("v1"))),
+ Set("Sort")),
+ ("limit", Nil, () => l.limit(5).groupBy("k1").count(),
Set("GlobalLimit")),
+ ("sample", Nil, () => l.sample(0.5, 1L), Set("Sample")),
+ ("union", Nil, () =>
l.select("k1").union(r.select("k2")).groupBy("k1").count(),
+ Set("Union")),
+ ("objects", Nil, () => spark.range(10).as[Long].map(_ * 2).filter(_ >
3).toDF(),
+ Set("MapElements")),
+ ("scalar and IN subqueries", noBroadcast, () => sql(
+ "SELECT k1, (SELECT max(v2) FROM r WHERE v2 < 5) FROM l " +
+ "WHERE k1 IN (SELECT k2 FROM r WHERE v2 > 3)"),
+ Set("Project")),
+ ("vectorized parquet scan", Nil, () => spark.table("p").where($"v1" >
3)
+ .groupBy("k1").count(), Set("ColumnarToRow")),
+ ("row-based parquet scan",
Seq(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> "false"),
+ () => spark.table("p").where($"v1" > 3).groupBy("k1").count(),
Set("Filter")),
+ ("cached table scan", Nil, () =>
spark.table("c").groupBy("k1").count(),
+ Set("HashAggregate", "Range")),
+ ("merge rows", Nil, () => {
+ val source = l.selectExpr("CAST(v1 AS INT) AS t", "CAST(k1 AS INT)
AS s")
+ val attrs = source.queryExecution.analyzed.output
+ classic.Dataset.ofRows(spark, MergeRows(
+ isSourceRowPresent = Literal.TrueLiteral,
+ isTargetRowPresent = Literal.TrueLiteral,
+ matchedInstructions = Seq(Keep(Update, Literal.TrueLiteral,
attrs)),
+ notMatchedInstructions = Nil,
+ notMatchedBySourceInstructions = Nil,
+ checkCardinality = false,
+ output = attrs.map(_.newInstance()),
+ child = source.queryExecution.analyzed))
+ }, Set("MergeRows")))
+ aggs ++ smj ++ shj ++ bhj ++ bnlj ++ rangeJoin ++ asOfJoin ++ others
+ }
+
+ withTempPath { dir =>
+ withTempView("l", "r", "p", "c") {
+ spark.range(0, 100, 1, 2).select(($"id" % 10).as("k1"), $"id".as("v1"))
+ .createOrReplaceTempView("l")
+ spark.range(0, 30, 1, 2).select(($"id" % 7).as("k2"), $"id".as("v2"))
+ .createOrReplaceTempView("r")
+ spark.table("l").write.parquet(dir.getCanonicalPath)
+ spark.read.parquet(dir.getCanonicalPath).createOrReplaceTempView("p")
+ // Not the plan of `l`, which the other queries would then read from
the cache.
+ val cached =
+ spark.range(0, 50, 1, 2).select(($"id" % 10).as("k1"),
$"id".as("v1")).cache()
+ cached.createOrReplaceTempView("c")
+ try {
Review Comment:
I split the cases with `gridTest`, so each case is its own test and runs its
4 configurations. The redundant cases you pointed out are removed, which leaves
53 cases. I kept the aggregate and join cases that overlap with the
SPARK-61661/61666/61668 tests: those tests only check the stages of their own
operator, while these check every stage of the query. All 53 take about 10
seconds together.
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala:
##########
@@ -904,6 +907,179 @@ class WholeStageCodegenSuite extends SharedSparkSession
}
}
+ test("SPARK-61761: Whole-stage codegen stages do not serialize plan nodes
into tasks") {
Review Comment:
Agreed, this test only covers the operators it lists. Checking `references`
directly in `WholeStageCodegenExec` would only see a plan node passed straight
to `addReferenceObj`. A plan node held inside a referenced helper object would
need a serialization walk like `serializedPlanNodes` for every stage in every
test, and that is not cheap. I'd rather leave that to a separate discussion
than add it here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]