Copilot commented on code in PR #58578:
URL: https://github.com/apache/spark/pull/58578#discussion_r3951164528
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala:
##########
@@ -1090,6 +1090,68 @@ class PlanParserSuite extends AnalysisTest {
$"t.a",
None,
Inner).select(star()))
+
+ assertEqual(
+ "select * from t asof join u match_condition (t.a > u.a)",
+ AsOfJoin.fromMatchCondition(
+ table("t"),
+ table("u"),
+ $"t.a",
+ GreaterThanOp,
+ $"u.a",
+ None,
+ Inner).select(star()))
+
+ assertEqual(
+ "select * from t asof join u match_condition (t.a < u.a)",
+ AsOfJoin.fromMatchCondition(
+ table("t"),
+ table("u"),
+ $"t.a",
+ LessThanOp,
+ $"u.a",
+ None,
+ Inner).select(star()))
+
+ assertEqual(
+ "select * from t inner asof join u match_condition (t.a >= u.a)",
+ AsOfJoin.fromMatchCondition(
+ table("t"),
+ table("u"),
+ $"t.a",
+ GreaterThanOrEqualOp,
+ $"u.a",
+ None,
+ Inner).select(star()))
+
+ assertEqual(
+ "select * from t left outer asof join u match_condition (t.a >= u.a)",
+ AsOfJoin.fromMatchCondition(
+ table("t"),
+ table("u"),
+ $"t.a",
+ GreaterThanOrEqualOp,
+ $"u.a",
+ None,
+ LeftOuter).select(star()))
+ }
+ }
+
+ test("asof join - struct match condition") {
+ withSQLConf(SQLConf.SQL_ASOF_JOIN_ENABLED.key -> "true") {
+ // A multi-column MATCH_CONDITION: `(a, b)` parses to a row constructor
(CreateStruct),
+ // and the top-level comparison must still be extracted as the match
operator so that
+ // STRUCT operands compare lexicographically (see the SQL reference for
ASOF JOIN).
+ assertEqual(
+ "select * from t asof join u match_condition ((t.a, t.b) >= (u.a,
u.b))",
+ AsOfJoin.fromMatchCondition(
+ table("t"),
+ table("u"),
+ CreateStruct($"t.a" :: $"t.b" :: Nil),
+ GreaterThanOrEqualOp,
+ CreateStruct($"u.a" :: $"u.b" :: Nil),
Review Comment:
Using `:: Nil` to build the struct field list is a bit harder to read and
more error-prone to extend than a sequence literal. Consider switching to a
clearer construction (e.g., `Seq(...)`), which also matches the common style
used elsewhere in Spark tests.
--
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]