You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add back Distinct for where-exists if subquery is a DISTINCT #5344
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
After #5264, we support rewriting more where-exists to join, but do not add back the Distinct.
For query:
SELECTt1.t1_idFROM t1
WHERE EXISTS(SELECT DISTINCT t2_int
FROM t2
WHEREt2.t2_id>t1.t1_id);
# current logical plan:
Projection: t1.t1_id
LeftSemi Join: Filter: t2.t2_id>t1.t1_id
TableScan: t1 projection=[t1_id]
Projection: t2.t2_id# DISTINCT is not added back
TableScan: t2 projection=[t2_id]
Although the execution result is correct, we should add back the DISTINCT.
In some cases, DISTINCT can filter a lot rows before join, we should let user choose.
Describe the solution you'd like
Add back Distinct if the subquery is a DISTINCT.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Activity