mikamikasuki opened a new pull request, #26060:
URL: https://github.com/apache/datafusion/pull/26060

   ## Which issue does this PR close?
   
   - Closes #25808.
   
   ## Rationale for this change
   
   The query in #25808 returns the same `(outer key, distinct value)` row more 
than once. Moving a correlated filter above `DISTINCT` makes rows that differ 
only in the filtered inner column appear distinct, even though that column is 
not part of the visible result.
   
   ## What changes are included in this PR?
   
   For the supported INNER LATERAL shape, apply the correlated filter before 
the DISTINCT aggregation. A unique row number on each outer input row preserves 
bag semantics when the outer input itself contains duplicates. Unsupported plan 
shapes continue through the existing decorrelation path.
   
   ## What is the testing strategy for this PR?
   
   Added `lateral_join.slt` regression cases for the issue query, duplicate 
outer rows, and explicit `JOIN LATERAL ... ON TRUE`. The issue case fails on 
the base commit and passes with this change. The optimizer unit and integration 
tests, focused lateral join sqllogictests, the extended workspace test suite, 
strict optimizer clippy, formatting, and `git diff --check` passed.
   
   ## Are there any user-facing changes?
   
   The affected LATERAL DISTINCT query now returns the expected distinct rows.


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