You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "dvasdekis (via GitHub)" <gi...@apache.org> on 2026/10/02 01:06:57 UTC
[PR] MSSQL: Support deferred ON clauses in right-nested joins [datafusion-sqlparser-rs]
dvasdekis opened a new pull request, #2606:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2606
MSSQL: Support deferred ON clauses in right-nested joins
`SELECT a.id FROM a LEFT JOIN b INNER JOIN c ON b.id = c.id ON a.id = b.id` currently fails with MsSqlDialect.
Enable the existing right-nested JOIN capability for MSSQL; preserve predicate ownership and outer-join grouping.
Test mixed join types, deeper chains, canonical round-trips, immediate-condition chains, and malformed predicates.
This only enables MSSQL: it does not duplicate the shared parser changes in #2445 or the recursion work in #2440.
Draft pending coordination with #2440 and #2445; follows the PostgreSQL enablement in #2377.
Syntax reference: https://learn.microsoft.com/en-us/sql/t-sql/queries/from-transact-sql
Validation: `cargo test --all-features`, formatting, strict all-target/all-feature Clippy, and a bounded parser fuzz run.
All examples and fixtures are synthetic.
Prepared with GitHub Copilot assistance.
--
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] MSSQL: Support deferred ON clauses in right-nested joins [datafusion-sqlparser-rs]
Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 commented on code in PR #2606:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2606#discussion_r4173632404
##########
tests/sqlparser_mssql.rs:
##########
@@ -2963,3 +2963,70 @@ fn parse_create_proc() {
.expect_err("PROC should remain MSSQL-specific");
ms_and_generic().verified_stmt("SELECT proc FROM jobs");
}
+
+#[test]
+fn parse_mssql_deferred_join_conditions() {
+ let sql = "SELECT a.id FROM a LEFT JOIN b INNER JOIN c ON b.id = c.id ON a.id = b.id";
+ let statement = ms().one_statement_parses_to(
+ sql,
+ "SELECT a.id FROM a LEFT JOIN (b INNER JOIN c ON b.id = c.id) ON a.id = b.id",
+ );
+ let Statement::Query(query) = statement else {
+ unreachable!()
+ };
+ let select = query.body.as_select().unwrap();
+ let outer_join = only(&only(&select.from).joins);
+ assert!(matches!(&outer_join.join_operator,
+ JoinOperator::Left(JoinConstraint::On(expr)) | JoinOperator::LeftOuter(JoinConstraint::On(expr))
+ if expr.to_string() == "a.id = b.id"));
+ let TableFactor::NestedJoin {
+ table_with_joins,
+ alias,
+ } = &outer_join.relation
+ else {
+ panic!("expected right-nested join");
+ };
+ assert!(alias.is_none());
+ let inner_join = only(&table_with_joins.joins);
+ assert!(matches!(&inner_join.join_operator,
+ JoinOperator::Join(JoinConstraint::On(expr)) | JoinOperator::Inner(JoinConstraint::On(expr))
+ if expr.to_string() == "b.id = c.id"));
+
+ for (sql, expected) in [
+ (
+ "SELECT * FROM a JOIN b JOIN c ON b.id = c.id ON a.id = b.id",
+ "SELECT * FROM a JOIN (b JOIN c ON b.id = c.id) ON a.id = b.id",
+ ),
+ (
+ "SELECT * FROM a FULL JOIN b RIGHT JOIN c ON b.id = c.id ON a.id = b.id",
+ "SELECT * FROM a FULL JOIN (b RIGHT JOIN c ON b.id = c.id) ON a.id = b.id",
+ ),
+ (
+ "SELECT * FROM a JOIN b JOIN c JOIN d ON c.id = d.id ON b.id = c.id ON a.id = b.id",
+ "SELECT * FROM a JOIN (b JOIN (c JOIN d ON c.id = d.id) ON b.id = c.id) ON a.id = b.id",
+ ),
+ ] {
+ ms().one_statement_parses_to(sql, expected);
+ }
+}
Review Comment:
Recursion red test
```suggestion
}
#[test]
fn parse_mssql_deferred_join_enforces_recursion_limit() {
let mut sql = String::from("SELECT * FROM t0");
for index in 1..=100 {
sql.push_str(&format!(" JOIN t{index}"));
}
for _ in 1..=100 {
sql.push_str(" ON 1 = 1");
}
let result = Parser::new(&MsSqlDialect {})
.with_recursion_limit(5)
.try_with_sql(&sql)
.and_then(|mut parser| parser.parse_statements());
assert_eq!(result, Err(ParserError::RecursionLimitExceeded));
}
```
##########
src/dialect/mssql.rs:
##########
@@ -65,6 +65,10 @@ impl Dialect for MsSqlDialect {
true
}
+ fn supports_left_associative_joins_without_parens(&self) -> bool {
Review Comment:
I suspect there may still be recursion stack overflows relative to this feature. Please bound join-parser recursion before enabling this dialect and assert `RecursionLimitExceeded` on a long chain with a small configured limit
The shared parser guard is tracked in [#2440](https://github.com/apache/datafusion-sqlparser-rs/pull/2440).
--
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] MSSQL: Support deferred ON clauses in right-nested joins [datafusion-sqlparser-rs]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2606:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2606#issuecomment-5947790806
## [Codecov](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/pull/2606?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 81.11%. Comparing base ([`fc18670`](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/commit/fc18670e60915d4d27b1a649b00e4facedd99d23?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f365b47`](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/commit/f365b47ca4dfa76dd488d2229d5fadaf295c26f7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #2606 +/- ##
=======================================
Coverage 81.11% 81.11%
=======================================
Files 42 42
Lines 33707 33710 +3
Branches 33707 33710 +3
=======================================
+ Hits 27342 27345 +3
Misses 2796 2796
Partials 3569 3569
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/pull/2606?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
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