yaooqinn opened a new pull request, #54140:
URL: https://github.com/apache/spark/pull/54140

   ### What changes were proposed in this pull request?
   
   This PR adds a new optimizer rule that converts cross joins with 
`array_contains` filter into efficient inner joins using explode. This 
transforms:
   
   ```sql
   SELECT * FROM orders, items WHERE array_contains(orders.item_ids, items.id)
   ```
   
   From O(N×M) cross join + filter to O(N+M) inner join:
   
   ```sql
   SELECT * FROM (SELECT *, explode(array_distinct(item_ids)) as _unnested FROM 
orders) t, items
   WHERE t._unnested = items.id
   ```
   
   ### Why are the changes needed?
   
   Cross joins with `array_contains` are common patterns that can be very 
expensive for large datasets. This optimization provides 10-15X speedup on 
realistic workloads.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No, this is an internal optimizer improvement.
   
   ### How was this patch tested?
   
   - Unit tests: 15 tests covering basic transformation, type support, and edge 
cases
   - Microbenchmark: 10K×1K dataset showing ~10-15X speedup
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Yes, GitHub Copilot CLI assisted with implementation.
   


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