[
https://issues.apache.org/jira/browse/FLINK-41039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18132575#comment-18132575
]
Yaoxuan Wu commented on FLINK-41039:
------------------------------------
Hi [~manish1337]
Thanks! I built the PR locally and tested it: all the buggy queries from this
issue, including the Table API form (minus_all / intersect_all + select) and
streaming mode, now return the correct results. I also ran a regression on the
planner with and without your change (500 randomly generated programs plus the
original failing one) and saw no other change in results.
LGTM, thanks for the fix!
> 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
> Priority: Major
> Labels: pull-request-available
>
> {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
(v10.3.26#10030026)