Skip to content

Commit e3d3721

Browse files
Backport #81754 to 25.5: Fix crash in ConcurrentHashJoin with empty USING ()
1 parent 196bae5 commit e3d3721

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

src/Interpreters/TableJoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ bool TableJoin::sameStrictnessAndKind(JoinStrictness strictness_, JoinKind kind_
576576

577577
bool TableJoin::oneDisjunct() const
578578
{
579-
return clauses.size() == 1;
579+
return clauses.size() == 1 && !clauses.front().isEmpty();
580580
}
581581

582582
bool TableJoin::needStreamWithNonJoinedRows() const

src/Interpreters/TableJoin.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ class TableJoin
121121
"Left keys: [{}] Right keys [{}] Condition columns: '{}', '{}'",
122122
fmt::join(key_names_left, ", "), fmt::join(key_names_right, ", "), left_cond, right_cond);
123123
}
124+
125+
bool isEmpty() const
126+
{
127+
return key_names_left.empty() && key_names_right.empty() && !on_filter_condition_left && !on_filter_condition_right
128+
&& analyzer_left_filter_condition_column_name.empty() && analyzer_right_filter_condition_column_name.empty();
129+
}
124130
};
125131

126132
using Clauses = std::vector<JoinOnClause>;

tests/queries/0_stateless/03538_crash_in_parallel_hash_with_empty_using.reference

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
set enable_parallel_replicas = 0;
2+
3+
SELECT
4+
n,
5+
myfield
6+
FROM
7+
(
8+
SELECT toString(number) AS n
9+
FROM system.numbers
10+
LIMIT 1000
11+
) AS a
12+
ANY LEFT JOIN
13+
(
14+
SELECT 1 AS myfield
15+
) AS b USING ()
16+
FORMAT Null
17+
SETTINGS allow_experimental_analyzer = false;
18+
19+
SELECT
20+
n,
21+
myfield
22+
FROM
23+
(
24+
SELECT toString(number) AS n
25+
FROM system.numbers
26+
LIMIT 1000
27+
) AS a
28+
ANY LEFT JOIN
29+
(
30+
SELECT 1 AS myfield
31+
) AS b USING ()
32+
FORMAT Null
33+
SETTINGS allow_experimental_analyzer = true; -- { serverError INVALID_JOIN_ON_EXPRESSION }

0 commit comments

Comments
 (0)