uros-b commented on code in PR #56101:
URL: https://github.com/apache/spark/pull/56101#discussion_r3683544650


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/joins/BroadcastNearestByJoinExecSuite.scala:
##########
@@ -0,0 +1,633 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.joins
+
+import java.sql.Date
+
+import org.apache.spark.sql.{QueryTest, Row}
+import org.apache.spark.sql.functions._
+import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.test.SharedSparkSession
+
+class BroadcastNearestByJoinExecSuite extends QueryTest with 
SharedSparkSession {
+
+  import testImplicits._
+
+  private def withStreamingHeap(f: => Unit): Unit = {
+    withSQLConf(
+      SQLConf.NEAREST_BY_BROADCAST_ENABLED.key -> "true",
+      SQLConf.CROSS_JOINS_ENABLED.key -> "true",
+      SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "10485760") { // 10MB
+      f
+    }
+  }
+
+  test("empty right table - INNER returns nothing") {
+    withStreamingHeap {
+      val left = spark.range(5).toDF("id").withColumn("x", 
col("id").cast("double"))
+      val right = spark.range(0).toDF("rid").withColumn("y", lit(0.0))
+      val result = left.nearestByJoin(right, abs(col("x") - col("y")),
+        numResults = 3, mode = "exact", direction = "distance")
+      val plan = result.queryExecution.executedPlan
+      assert(plan.treeString.contains("BroadcastNearestByJoin"),

Review Comment:
   There is no rewrite-vs-operator parity test. Every flag-on test asserts 
treeString.contains("BroadcastNearestByJoin") and then checks a hand-computed 
expected answer; the one flag-off test uses a different query. Both prior 
reviewers had to establish operator/rewrite equivalence by hand, twice, and 
that is precisely the property the flag's contract depends on. Running each 
case with the flag on and off and calling checkAnswer on the two results would 
pin it mechanically and would incidentally cover the gaps the current suite has 
(LEFT OUTER with a non-empty right whose ranking values are all null, and 
per-left-row result ordering).



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