dongjoon-hyun commented on code in PR #60030:
URL: https://github.com/apache/spark/pull/60030#discussion_r4470331645
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/KeyGroupedPartitioningSuite.scala:
##########
@@ -511,6 +511,82 @@ trait KeyGroupedPartitioningRuntimeFilterTests extends
KeyGroupedPartitioningSui
}
}
}
+
+ /**
+ * Runs `f` over `items` and `purchases`, both partitioned by the ids 1 to
7, with `rowsPerKey`
+ * rows in each `purchases` key, under the confs of a DPP subquery that
reuses no broadcast.
+ */
+ private def withDppSubqueryTables(rowsPerKey: Int)(f: => Unit): Unit = {
+ withSQLConf(
+ SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+ SQLConf.DYNAMIC_PARTITION_PRUNING_ENABLED.key -> "true",
+ SQLConf.DYNAMIC_PARTITION_PRUNING_REUSE_BROADCAST_ONLY.key -> "false",
+ SQLConf.DYNAMIC_PARTITION_PRUNING_FALLBACK_FILTER_RATIO.key -> "10") {
+ createTable(items, itemsColumns, Array(identity("id")))
+ sql(s"INSERT INTO testcat.ns.$items VALUES " + (1 to 7).map(i =>
+ s"($i, 'x', 10.0, cast('2020-01-01' as timestamp))").mkString(", "))
+ createTable(purchases, purchasesColumns, Array(identity("item_id")))
+ sql(s"INSERT INTO testcat.ns.$purchases VALUES " + (1 to 7).flatMap(i =>
+ Seq.fill(rowsPerKey)(s"($i, $i.0, cast('2020-01-01' as
timestamp))")).mkString(", "))
+ f
+ }
+ }
+
+ /**
+ * Checks the rows of `query`, and that its join plans no shuffle. With AQE
off only, since with
+ * AQE on the copies of the join's scan plan their partitions when the
result stage is created,
+ * before the DPP subquery prunes the shared `Scan`.
+ */
+ private def checkStoragePartitionedJoin(query: String, expected: Seq[Row]):
Unit = {
+ withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "false") {
+ val df = sql(query)
+ checkAnswer(df, expected)
+ val plan = df.queryExecution.executedPlan
+ assert(collectShuffles(plan).isEmpty,
Review Comment:
**23. [Nit] The new tests do not check the plan shape they rely on**
This checks the rows and that `collectShuffles(plan)` is empty, but
`collectShuffles` only looks under a `SortMergeJoinExec` (L99-L107), so it is
also empty when there is no sort-merge join. Nothing checks that the join is a
sort-merge join, that `items` gets the DPP subquery, or, in the nested test,
that a `GroupPartitionsExec` groups `purchases` as its comment says
(L571-L572). Both tests rely on `fallbackFilterRatio = 10` for the DPP
subquery. If a planner change dropped it or planned another join, no build side
would prune the shared `Scan` first, and both tests would pass with or without
the sharing. The `check` of the SPARK-60260 test above asserts each of these
(L410-L417). For example:
```scala
assert(collect(plan) { case j: SortMergeJoinExec => j }.nonEmpty,
s"Expected a sort-merge join:\n$plan")
assert(collectScans(plan).exists(
_.runtimeFilters.exists(_.isInstanceOf[DynamicPruningExpression])),
s"Expected a DPP filter on a scan:\n$plan")
```
with `DynamicPruningExpression` added to the imports, and
`collectGroupPartitions(plan).nonEmpty` in the nested test.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/BatchScanExec.scala:
##########
@@ -181,3 +184,25 @@ case class BatchScanExec(
s"BatchScan ${table.name()}".trim
}
}
+
+/**
+ * A `Scan`, with the `Batch` and the input partitions a [[BatchScanExec]]
plans from it once, when
Review Comment:
**25. [Nit] The docs of the holder do not mention the reader factory**
Since item 17 the holder builds three things once (L201-L203), but this
sentence and the `@param` at L42-L43 still list only "the `Batch` and the input
partitions", and nothing says that the copies share one reader factory. The
description already has the wording: "with the `Batch`, its reader factory and
the input partitions planned from it once". Using it here, with the `@param`
just pointing to `PlannedScan`, would keep the reason for the shared factory
next to the code.
--
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]