Lordworms commented on PR #11897:
URL: https://github.com/apache/datafusion/pull/11897#issuecomment-2283117320

   > > the only way for us to know whether return an empty set or a null is in 
execution
   > 
   > What is the reason that we could not determine the result in the the 
optimizer? Is there any counter example that does not work if we rewrite 
expression and could only be determined in execution?
   > 
   > InList is one of the example that returns empty set and it is rewritten 
early in ExprSimplifier
   > 
   > ```
   > query I
   > select x from t where x IN (1,2,3) AND x IN (4,5);
   > ----
   > 
   > query TT
   > explain select x from t where x IN (1,2,3) AND x IN (4,5);
   > ----
   > logical_plan EmptyRelation
   > physical_plan EmptyExec
   > ```
   
   The point is not the optimizer actually,  for example(using offical release 
of DF and duckdb)
   
![image](https://github.com/user-attachments/assets/29fa24d8-d9cb-44ab-abb0-05f9bbba7616)
   
   we should generate an empty set when having is true and group_by is a 
constant
   
   I was doing similar optimize things in the begining, but after alamb asked 
me to add tests when having is true. I found out this problem.
   


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