Skip to content

Fix crash in not equi join on#15162

Merged
alexey-milovidov merged 8 commits intoClickHouse:masterfrom
4ertus2:joins
Jan 4, 2021
Merged

Fix crash in not equi join on#15162
alexey-milovidov merged 8 commits intoClickHouse:masterfrom
4ertus2:joins

Conversation

@4ertus2
Copy link
Copy Markdown
Contributor

@4ertus2 4ertus2 commented Sep 22, 2020

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix crash in case of not equi-join ON expression in RIGH|FULL JOIN.

Fixes #14627
Related to #8802

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Sep 22, 2020
@4ertus2
Copy link
Copy Markdown
Contributor Author

4ertus2 commented Sep 23, 2020

The problem with PR is distributed queries expect ON with _shard_num working

SELECT * FROM a JOIN b ON _shard_num = b.shard_num

@4ertus2 4ertus2 marked this pull request as draft September 23, 2020 10:15
@alexey-milovidov alexey-milovidov marked this pull request as ready for review December 20, 2020 05:28
@alexey-milovidov alexey-milovidov self-assigned this Dec 20, 2020
@PHaroZ
Copy link
Copy Markdown

PHaroZ commented Jan 18, 2021

Hi,

This PR breaks a lots of queries in my app : queries like

SELECT
	t.value,
	i18n.title
FROM
	aTable t
	LEFT ANY JOIN aTable_i18n i18n
	          ON i18n.ref_id = t.id AND i18n.lang = 'en'

Is it really what you wanted or it's an unexpected side-effect ?

@vlauzeckas
Copy link
Copy Markdown

yes, new version of clickhouse corrupts number of queries:

SELECT * FROM (SELECT NULL AS a, 1 AS b) AS foo RIGHT JOIN (SELECT 1024 AS b) AS bar ON 1 = foo.b;

throws error: Not equi-join ON expression: 1 = b. No columns in one of equality side.: While processing 1 = b

whats wrong in joining on value=column? works in any other database

@vdimir
Copy link
Copy Markdown
Member

vdimir commented Mar 18, 2021

@jobosk Seems that it's different case.

Now conditions that is not in the form t1.col1 = t2.col2 where t1 and t2 different tables is not supported, except case of INNER join (for such cases conditions moved to WHERE on query processing, see #18720). Conditions that depends on one table in ON and WHERE sections have slightly different semantic (see #19685 (comment)).

We considered to support such conditions in ON section, but now there's no ETA for this. I'll create an issue.

UPD: Comment by @jobosk to that I answered had been deleted from this thread

@jobosk
Copy link
Copy Markdown

jobosk commented Mar 19, 2021

@jobosk Seems that it's different case.

Now conditions that is not in the form t1.col1 = t2.col2 where t1 and t2 different tables is not supported, except case of INNER join (for such cases conditions moved to WHERE on query processing, see #18720). Conditions that depends on one table in ON and WHERE sections have slightly different semantic (see #19685 (comment)).

We considered to support such conditions in ON section, but now there's no ETA for this. I'll create an issue.

UPD: Comment by @jobosk to that I answered had been deleted from this thread

Sorry! I deleted my comment after updating to 21.3.2.5, and not having an issue with that version I assumed it was fixed afterwards. Didn't see your reply, the page must've been cached.

For anyone who wonders what it was about: I had a problem after migrating to server v21.1.7.1 using conditions like r1.col1 = 'string' in the ON section of my JOIN.

Since I deleted my comment and don't have access to the code right now, I'm not sure wether it was an INNER JOIN and it was indeed a problem with that version later fixed, or if wasn't, in which case I'm not really sure why it does work with later versions. I'll let you know as soon as I have access to the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug assertion: Wrong columns assign in RIGHT|FULL JOIN: UInt8 UInt16

7 participants