[ON | USING] ... [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] MySQL: Support CROSS JOIN
[ON | USING] ... [datafusion-sqlparser-rs]
Posted by "rs-sac (via GitHub)" <gi...@apache.org>.
rs-sac commented on code in PR #2025:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2025#discussion_r2337189458
##########
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:
Done.
##########
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:
Done.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org