New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move conditions from JOIN ON to WHERE #18720
Comments
assign to me |
@hexiaoting Ok. Thank you in advance! |
@alexey-milovidov I have two questions: Q2: |
@alexey-milovidov I need some help, related to above questions. Thank you. |
@hexiaoting sorry for long delay.
It's very close to query in first comment of this issue, so correct behavior is
It should not be allowed as it is now. |
@vdimir yeah, I have implemented this optimization and now the behavior is same with your opinion. |
Closed via #19685 |
I think this could lead to error with 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 = 1 is 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 = 1 The first one should return a line while the second returns anything because it joins on the first machting line with 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; |
@PHaroZ makes sense, thank you for your notice. We are going to fix it. |
Use case
Conditions that are not related to JOIN:
t1 JOIN t2 ON t1.k = t2.k AND t1.hello = 'world'
should be transformed to:
t1 JOIN t2 ON t1.k = t2.k WHERE t1.hello = 'world'
otherwise it does not work.
The text was updated successfully, but these errors were encountered: