Yaoxuan Wu created FLINK-41039:
----------------------------------

             Summary:   A projection on top of EXCEPT ALL or INTERSECT ALL is 
pushed into both inputs and changes the result
                 Key: FLINK-41039
                 URL: https://issues.apache.org/jira/browse/FLINK-41039
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
    Affects Versions: 2.3.0
            Reporter: Yaoxuan Wu


{code:sql}
SELECT x, y FROM (VALUES (1, 10)) AS a(x, y)
EXCEPT ALL
SELECT x, y FROM (VALUES (2, 10)) AS b(x, y);
-- (1, 10)   correct

SELECT y FROM (
  SELECT x, y FROM (VALUES (1, 10)) AS a(x, y)
  EXCEPT ALL
  SELECT x, y FROM (VALUES (2, 10)) AS b(x, y));
-- expected: 10
-- actual:   (no rows)
{code}
{{ProjectSetOpTransposeRule}} pushes the projection {{y}} into both inputs, so 
the EXCEPT ALL is computed on {{y}} alone and the two rows cancel. The rule 
only refuses distinct set operations, but pushing a projection is only safe for 
UNION ALL. INTERSECT ALL is wrong in the same way (it returns rows that should 
not match). Streaming mode is affected too.

Reproduces on 2.0.1, 2.2.1, 2.3.0 and master.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to