cloud-fan commented on code in PR #58657:
URL: https://github.com/apache/spark/pull/58657#discussion_r4033931606


##########
sql/core/src/test/scala/org/apache/spark/sql/AsOfJoinSortMergeSQLSuite.scala:
##########
@@ -159,6 +159,37 @@ class AsOfJoinSortMergeSQLSuite extends QueryTest
         Timestamp.valueOf("2026-06-29 12:00:00")) :: Nil)
   }
 
+  test("MATCH_CONDITION with the right operand written first (<=) is a 
backward match") {
+    setupTradeQuoteViews()
+    // q.quote_time <= t.trade_time normalizes to t.trade_time >= q.quote_time.
+    checkSortMergeAsOf(
+      sql(
+        """
+          |SELECT t.trade_time, t.symbol, q.bid_price
+          |FROM trades t ASOF JOIN quotes q
+          |  MATCH_CONDITION (q.quote_time <= t.trade_time)
+          |  ON t.symbol = q.symbol
+          |""".stripMargin),
+      Seq(
+        Row(Timestamp.valueOf("2026-06-29 10:00:05"), "AAPL", 180.10),
+        Row(Timestamp.valueOf("2026-06-29 10:00:11"), "AAPL", 180.20),
+        Row(Timestamp.valueOf("2026-06-29 10:00:12"), "MSFT", 420.50)))
+  }
+
+  test("MATCH_CONDITION with the right operand written first (>=) is a forward 
match") {
+    setupTradeQuoteViews()
+    // q.quote_time >= t.trade_time normalizes to t.trade_time <= q.quote_time.
+    checkSortMergeAsOf(
+      sql(
+        """
+          |SELECT t.trade_time, t.symbol, q.bid_price
+          |FROM trades t ASOF JOIN quotes q
+          |  MATCH_CONDITION (q.quote_time >= t.trade_time)

Review Comment:
   **Non-blocking (P2):** `q.quote_time >= t.trade_time` is meant to normalize 
to the inclusive `t.trade_time <= q.quote_time`, but this fixture only has 
10:00:05 on the left and selects the 10:00:07 quote. The same row is returned 
if the normalized operator accidentally becomes strict `<`, so this test cannot 
catch the boundary regression it names. Please add an equal-timestamp case (or 
an equivalent exact-plan assertion) for this arm.



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