-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Correct move conditions from JOIN ON to WHERE for ANY JOIN` #21671
Copy link
Copy link
Closed
Labels
comp-joinsJOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla...JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla...comp-query-optimizerQuery plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa...Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa...feature
Description
I think this could lead to error with . A query like
SELECT *
FROM
(SELECT 1 AS id) AS l
INNER ANY JOIN (SELECT 1 AS id, number as v FROM system.numbers LIMIT 2) AS r
ON l.id = r.id AND r.v = 1is not the same as
SELECT *
FROM
(SELECT 1 AS id) AS l
INNER ANY JOIN (SELECT 1 AS id, number as v FROM system.numbers LIMIT 2) AS r
ON l.id = r.id
WHERE
r.v = 1The first one should return a line while the second returns anything because it joins on the first machting line with and then apply .
IMHO the where clause should be added to a subselect like
SELECT *
FROM
(SELECT 1 AS id) AS l
INNER ANY JOIN (SELECT * FROM (SELECT 1 AS id, number AS v FROM system.numbers LIMIT 2) WHERE v = 1) AS r
ON l.id = r.id;Originally posted by @PHaroZ in #18720 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
comp-joinsJOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla...JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla...comp-query-optimizerQuery plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa...Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa...feature