-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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:
SELECT t1.t1_id
FROM t1
WHERE EXISTS(SELECT DISTINCT t2_int
FROM t2
WHERE t2.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.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request