LuciferYang commented on code in PR #60387:
URL: https://github.com/apache/spark/pull/60387#discussion_r4612264969


##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala:
##########
@@ -1014,6 +1014,20 @@ class JDBCV2Suite extends SharedSparkSession with 
ExplainSuiteHelper {
     checkAnswer(df2, Seq(Row(2, "david", 10000.00)))
   }
 
+  test("SPARK-61173: a scan with a pushed aggregate reads the same rows again, 
unless a top N " +
+    "follows it") {
+    def scanOf(df: DataFrame): DataSourceV2ScanRelation =
+      df.queryExecution.optimizedPlan.collectFirst { case r: 
DataSourceV2ScanRelation => r }
+        .getOrElse(fail(s"no scan in:\n${df.queryExecution.optimizedPlan}"))
+    val agg = 
spark.read.table("h2.test.employee").groupBy("DEPT").sum("SALARY")
+    checkAggregateRemoved(agg)
+    assert(scanOf(agg).repeatableRead && !scanOf(agg).onlyRowWisePushdowns)
+    val topN = agg.orderBy("DEPT").limit(1)

Review Comment:
   Done in ffe633321db. The `topN` half moved into the next test as 
`assert(!scanOf(topN1).repeatableRead)`, and `scanOf` is a private helper of 
the suite.



-- 
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]

Reply via email to