ulysses-you commented on a change in pull request #35473:
URL: https://github.com/apache/spark/pull/35473#discussion_r811809065
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala
##########
@@ -2484,6 +2491,38 @@ class AdaptiveQueryExecSuite
}
}
}
+
+ test("SPARK-38162: Optimize one row plan in AQE Optimizer") {
+ withTempView("v") {
+ spark.sparkContext.parallelize(
+ (1 to 4).map(i => TestData( i, i.toString)), 2)
+ .toDF("c1", "c2").createOrReplaceTempView("v")
+
+ // remove sort
+ val (origin1, adaptive1) = runAdaptiveAndVerifyResult(
+ """
+ |SELECT * FROM v where c1 = 1 order by c1, c2
+ |""".stripMargin)
+ assert(findTopLevelSort(origin1).size == 1)
+ assert(findTopLevelSort(adaptive1).isEmpty)
+
+ // convert group only aggregate to project
+ val (origin2, adaptive2) = runAdaptiveAndVerifyResult(
+ """
+ |SELECT distinct c1 FROM (SELECT /*+ repartition(c1) */ * FROM v
where c1 = 1)
Review comment:
nothing happens, the aggregate node is inside the logical query stage,
so we can not optimize it at logical side:
`LogicalQueryStage(logicalAgg: Aggregate, physicalAgg: BaseAggregateExec)`
And the plan inside physicalAgg:
```sql
BaseAggregateExec final
ShuffleQueryStage
Exchange
BaseAggregateExec partial
```
--
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]