Lordworms commented on PR #11897: URL: https://github.com/apache/datafusion/pull/11897#issuecomment-2283118351
> > > 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)  > > 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. I think we should control the AggExec's behaviour so I added this new field `is_global_group_by` -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org