revitalkr opened a new pull request, #2445:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2445
## Summary
For dialects with `supports_left_associative_joins_without_parens = false`,
nested joins are currently created even when no deferred join constraint exists.
## Problem
The non-left-associative join handling was introduced to support deferred
join constraints such as:
A JOIN B JOIN C ON X ON Y
However, the same logic is also applied to queries such as:
A JOIN B LEFT JOIN C ON X
even though there is no deferred ON or USING constraint to attach.
This produces a nested join structure where a flat join chain is expected.
## Solution
Only apply the nesting logic when a deferred join constraint (ON or USING)
remains to be attached.
Queries without deferred constraints continue to use the normal flat join
structure.
## Test
Adds coverage for:
SELECT 'ORIGINAL' AS src,
o.order_id,
c.customer_id,
p.product_id
FROM orders AS o
JOIN customers AS c
LEFT JOIN products AS p
ON p.order_id = o.order_id
and verifies that both Generic and Snowflake dialects produce a flat join
chain (joins.len() == 2).
## Validation - Snowflake script
The following query executes successfully in Snowflake:
SELECT 'ORIGINAL' AS src,
o.order_id,
c.customer_id,
p.product_id
FROM orders AS o
JOIN customers AS c
LEFT JOIN products AS p
ON p.order_id = o.order_id;
and matches the flat interpretation:
(orders AS o JOIN customers AS c)
LEFT JOIN products AS p
ON p.order_id = o.order_id
while the nested interpretation generated by the current
non-left-associative handling:
orders AS o
JOIN (
customers AS c
LEFT JOIN products AS p
ON p.order_id = o.order_id
)
is rejected by Snowflake.
--
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]