revitalkr opened a new pull request, #2355:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2355

   …R JOIN in Snowflake dialect produces non-equivalent query
   Closes #2353
   
   The current canonicalization rewrites queries such as:
   
   SELECT *
   FROM t1
   NATURAL JOIN t5
   INNER JOIN t0 ON (t0.v1 + t5.v0) > 0
   
   into:
   
   t1 NATURAL JOIN (t5 INNER JOIN t0 ...)
   
   This transformation is not semantics-preserving.
   
   NATURAL JOIN implicitly generates join predicates based on all shared column 
names.
   Moving t0 into the right-hand side of the NATURAL JOIN changes the set of 
visible columns, which may introduce additional implicit join conditions and 
lead to different results.
   
   Minimal example (see issue for full repro):
   
   SELECT *
   FROM t1
   NATURAL JOIN t5
   INNER JOIN t0 ON (t0.v1 + t5.v0) > 0
   
   Expected behavior:
   The canonicalization should preserve semantics, e.g.:
   
   (t1 NATURAL JOIN t5) INNER JOIN t0 ...
   
   Fix:
   Avoid right-associative parsing when NATURAL JOIN is present, ensuring that 
NATURAL JOIN is evaluated left-to-right.
   
   Tests:
   - Fixed the `join_precedence` test, which previously assumed incorrect 
Snowflake behavior.
   - Verified the actual behavior against Snowflake.
   - Updated the test to reflect the behavior observed in 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]

Reply via email to