dwsmith1983 commented on code in PR #6785:
URL: https://github.com/apache/datafusion-comet/pull/6785#discussion_r4707430187


##########
spark/src/test/scala/org/apache/comet/exec/CometJoinSuite.scala:
##########
@@ -1404,19 +1422,491 @@ class CometJoinSuite extends CometTestBase {
   // output ordering satisfies it, so the window needs that ordering restored 
too.
   for (adaptive <- Seq(false, true)) {
     test(s"forceShuffledHashJoin restores ordering for a window over the join, 
AQE=$adaptive") {
+      withForcedShjTables(adaptive) {
+        val (_, cometPlan) = checkSparkAnswer(
+          "SELECT big._1, big._2, small._2, count(*) OVER (PARTITION BY 
big._1) " +
+            "FROM big JOIN small ON big._1 = small._1")
+        assert(collect(cometPlan) { case j: CometHashJoinExec => j }.nonEmpty, 
cometPlan)
+        assert(collect(cometPlan) { case w: CometWindowExec => w }.nonEmpty, 
cometPlan)
+      }
+    }
+  }
+
+  test("forceShuffledHashJoin chain keeps early join dynamic filtering") {
+    withForcedShjTables(adaptive = false) {
+      val query = "SELECT big._1, big._2, mid._2, small._2 FROM big " +
+        "JOIN mid ON big._1 = mid._1 JOIN small ON big._1 = small._1"
+      for (enabled <- Seq(false, true)) {
+        withSQLConf(CometConf.COMET_EXEC_JOIN_DYNAMIC_FILTER_ENABLED.key -> 
enabled.toString) {
+          val (_, plan) = checkSparkAnswerAndOperator(sql(query))
+          val joins = collect(plan) { case join: CometHashJoinExec => join }
+          assert(joins.map(_.buildSide) == Seq(BuildRight, BuildRight), plan)
+          // big has 100 rows per key, mid 30, and small one row for keys 0 to 
90 by 10.
+          val outputs = joins.map(_.metrics("output_rows").value).sorted
+          assert(outputs == (if (enabled) Seq(30000L, 30000L) else Seq(30000L, 
300000L)))
+          if (enabled) {
+            assert(
+              
joins.map(_.metrics("dynamic_filter_early_rows_evaluated").value).sum == 10000L)
+            
assert(joins.map(_.metrics("dynamic_filter_early_rows_pruned").value).sum == 
9000L)
+          } else {
+            
assert(joins.forall(!_.metrics.contains("dynamic_filter_early_rows_pruned")))
+          }
+        }
+      }
+    }
+  }
+
+  private def checkPartitionsSortedOverHashJoin(df: => DataFrame): Unit = {

Review Comment:
   > Could this reuse `sameRowsAsSpark` and `partitionsInOrder`?
   
   Done in cb3c480e8. Each check now prints the plan, so with the planner 
change reverted the failure reads `inOrder was false *(1) CometColumnarToRow 
...` and continues with the rest of the plan. I also dropped the FULL join 
cases from these tests: on Spark 3.5 through 4.2 a full outer sort-merge join 
reports no output ordering, so Spark keeps that sort and they passed with the 
fix reverted.
   



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