asolimando commented on issue #21310:
URL: https://github.com/apache/datafusion/issues/21310#issuecomment-4254359545

   > [@asolimando](https://github.com/asolimando) You're right to push back — I 
overstated it. PostgreSQL does not have a dedicated UNION-to-OR rewriter. What 
I was thinking of is the combination of Append node flattening and constraint 
exclusion (`constraint_exclusion`) that can prune unnecessary branches at plan 
time, but that's not the same thing as rewriting UNION into OR predicates. I 
should have been more precise rather than citing a mechanism that doesn't exist 
in that form.
   > 
   > The point about skipping the rewrite when either branch contains LIMIT 
stands on its own merits regardless — the non-determinism argument doesn't 
depend on a PostgreSQL precedent.
   > 
   > Thanks for catching that.
   
   Thanks for the clarification!
   
   When you mention the "non-determinism argument" you mean the `(SELECT a FROM 
t WHERE x LIMIT 5) UNION (SELECT a FROM t WHERE y LIMIT 5)` cannot be rewritten 
as `SELECT DISTINCT a FROM t WHERE x OR y LIMIT 10`.
   
   Could you please explain why you think the rewrite is incorrect? Given that 
`SELECT * FROM ... WHERE ... LIMIT k` is non-deterministic in itself according 
to the SQL standard, the proposed rewrite is a legal option, although not the 
only possible one, this doesn't make the rewrite incorrect.


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