Skip to content

Commit a1525ab

Browse files
Backport #93038 to 25.12: Proper handle sparse nullable columns in inner/left joins
1 parent 4b2fbdc commit a1525ab

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/Interpreters/JoinUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void removeColumnNullability(ColumnWithTypeAndName & column)
234234

235235
if (column.column && column.column->isNullable())
236236
{
237-
column.column = column.column->convertToFullColumnIfConst();
237+
column.column = column.column->convertToFullIfNeeded();
238238
const auto * nullable_col = checkAndGetColumn<ColumnNullable>(column.column.get());
239239
if (!nullable_col)
240240
{

tests/queries/0_stateless/03773_nullable_sparse_join.reference

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
DROP TABLE IF EXISTS t1;
2+
DROP TABLE IF EXISTS t2;
3+
4+
SET max_partitions_per_insert_block=99999999;
5+
SET compatibility='23.3';
6+
7+
CREATE TABLE t1 (`c1` String, `c3` String, `c2` DateTime) ENGINE = MergeTree PARTITION BY toYYYYMM(c2) ORDER BY c1;
8+
CREATE TABLE t2 (`c4` Int64) ENGINE = MergeTree ORDER BY c4;
9+
10+
INSERT INTO t1 SELECT * FROM generateRandom() LIMIT 9;
11+
INSERT INTO t2 SELECT * FROM generateRandom() LIMIT 9;
12+
13+
SELECT lo.c4 FROM t1 AS l INNER JOIN t2 AS lo ON toInt64OrNull(l.c3) = lo.c4 FORMAT NULL;
14+
15+
DROP TABLE t1;
16+
DROP TABLE t2;

0 commit comments

Comments
 (0)