mustafasrepo commented on PR #11203:
URL: https://github.com/apache/datafusion/pull/11203#issuecomment-2203369671

   > Looks like my comment [#11203 
(comment)](https://github.com/apache/datafusion/pull/11203#discussion_r1662588836)
 was in progress when @viirya changed the code in 
[17b2d43](https://github.com/apache/datafusion/commit/17b2d431e44c07fdb6ffc3f4c81c3add0ba0783a)
   > 
   > Can someone help me understand what additional case this would catch (and 
I'll go and write some tests that cover it)?
   
   I have constructed an example that triggers this test case (query is a bit 
weird. I have constructed it to trigger `extract_or_clauses_for_join` call):
   ```
   explain SELECT e.emp_id, e.name, d.dept_name
   FROM employees AS e
   LEFT JOIN department AS d
   ON e.emp_id = d.emp_id
   WHERE ((dept_name != 'Engineering' AND e.name = 'Alice') OR (name != 'Alice' 
AND e.name = 'Carol'));
   ```
   this query generates following plan with recent changes
   ```
   +   logical_plan
   +   01)Filter: d.dept_name != Utf8("Engineering") AND e.name = Utf8("Alice") 
OR e.name != Utf8("Alice") AND e.name = Utf8("Carol")
   +   02)--Projection: e.emp_id, e.name, d.dept_name
   +   03)----Left Join: e.emp_id = d.emp_id
   +   04)------SubqueryAlias: e
   +   05)--------Filter: employees.name = Utf8("Alice") OR employees.name != 
Utf8("Alice") AND employees.name = Utf8("Carol")
   +   06)----------TableScan: employees projection=[emp_id, name]
   +   07)------SubqueryAlias: d
   +   08)--------TableScan: department projection=[emp_id, dept_name]
   ```
   previously it was generating
   ```
   +   logical_plan
   +   01)Filter: d.dept_name != Utf8("Engineering") AND e.name = Utf8("Alice") 
OR e.name != Utf8("Alice") AND e.name = Utf8("Carol")
   +   02)--Projection: e.emp_id, e.name, d.dept_name
   +   03)----Left Join: e.emp_id = d.emp_id
   +   04)------SubqueryAlias: e
   +   05)--------TableScan: employees projection=[emp_id, name]
   +   06)------SubqueryAlias: d
   +   07)--------TableScan: department projection=[emp_id, dept_name]
   ```
   where both are correct. However, first plan is a bit better


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