vranes commented on code in PR #58657:
URL: https://github.com/apache/spark/pull/58657#discussion_r4035252517
##########
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:
Done, added a separate test that has the quotes fixture on the right and a
single inline trade at 10:00:07 (equal to the AAPL quote) on the left.
Inclusive <= returns 180.15, a strict < would skip the equal quote and return
180.20. Thanks!
--
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]