Re: [PR] MySQL: Support CROSS JOIN [ON | USING] ... [datafusion-sqlparser-rs]

Fri, 19 Sep 2025 04:50:42 -0700


iffyio commented on code in PR #2025:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2025#discussion_r2336313470


##########
tests/sqlparser_mysql.rs:
##########
@@ -4132,6 +4132,40 @@ fn parse_straight_join() {
         .verified_stmt("SELECT a.*, b.* FROM table_a STRAIGHT_JOIN table_b AS 
b ON a.b_id = b.id");
 }
 
+#[test]
+fn parse_cross_join_on() {
+    let sql = "SELECT * FROM t1 CROSS JOIN t2 ON a = b";
+    let select = mysql().verified_only_select(sql);
+    assert_eq!(
+        Join {
+            relation: 
table_from_name(ObjectName::from(vec![Ident::new("t2")])),
+            global: false,
+            join_operator: 
JoinOperator::CrossJoin(JoinConstraint::On(Expr::BinaryOp {
+                left: Box::new(Expr::Identifier(Ident::new("a"))),
+                op: BinaryOperator::Eq,
+                right: Box::new(Expr::Identifier(Ident::new("b"))),
+            })),
+        },
+        only(only(select.from).joins),
+    );
+}
+
+#[test]
+fn parse_cross_join_using() {

Review Comment:
   Can we merge this test case into the one above as a generic `fn 
parse_cross_join_constraint()` test case? since they are the same feature



##########
tests/sqlparser_mysql.rs:
##########
@@ -4132,6 +4132,40 @@ fn parse_straight_join() {
         .verified_stmt("SELECT a.*, b.* FROM table_a STRAIGHT_JOIN table_b AS 
b ON a.b_id = b.id");
 }
 
+#[test]
+fn parse_cross_join_on() {
+    let sql = "SELECT * FROM t1 CROSS JOIN t2 ON a = b";
+    let select = mysql().verified_only_select(sql);

Review Comment:
   ```suggestion
       let dialect = all_dialects_where(|d| d.supports_cross_join_constraint());
       let select = dialect.verified_only_select(sql);
   ```
   can we do something like this instead, so that new dialects are 
automatically covered by this test case in the future (we could likely move 
this test to sqlparser_common.rs as a result too)



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