mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
join_use_nulls: development; added test [#CLICKHOUSE-4].
This commit is contained in:
parent
928b8d7653
commit
ab215c0fcd
@ -252,8 +252,9 @@ static void convertColumnToNullable(ColumnWithTypeAndName & column)
|
||||
|
||||
column.type = std::make_shared<DataTypeNullable>(column.type);
|
||||
|
||||
column.column = std::make_shared<ColumnNullable>(column.column,
|
||||
std::make_shared<ColumnConstUInt8>(column.column->size(), 0)->convertToFullColumn());
|
||||
if (column.column)
|
||||
column.column = std::make_shared<ColumnNullable>(column.column,
|
||||
std::make_shared<ColumnConstUInt8>(column.column->size(), 0)->convertToFullColumn());
|
||||
}
|
||||
|
||||
|
||||
@ -301,7 +302,7 @@ void Join::setSampleBlock(const Block & block)
|
||||
/// In case of LEFT and FULL joins, if use_nulls, convert joined columns to Nullable.
|
||||
if (use_nulls && (kind == ASTTableJoin::Kind::Left || kind == ASTTableJoin::Kind::Full))
|
||||
for (size_t i = 0; i < num_columns_to_add; ++i)
|
||||
convertColumnToNullable(sample_block_with_keys.getByPosition(i));
|
||||
convertColumnToNullable(sample_block_with_columns_to_add.getByPosition(i));
|
||||
}
|
||||
|
||||
|
||||
@ -983,8 +984,12 @@ public:
|
||||
|
||||
/// If use_nulls, convert left columns to Nullable.
|
||||
if (parent.use_nulls)
|
||||
{
|
||||
for (size_t i = 0; i < num_columns_left; ++i)
|
||||
{
|
||||
convertColumnToNullable(result_sample_block.getByPosition(column_numbers_left[i]));
|
||||
}
|
||||
}
|
||||
|
||||
columns_left.resize(num_columns_left);
|
||||
columns_keys_and_right.resize(num_keys + num_columns_right);
|
||||
|
@ -0,0 +1,80 @@
|
||||
5 5 5
|
||||
6 6 6
|
||||
7 7 7
|
||||
8 8 8
|
||||
9 9 9
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5 5
|
||||
6 6 6
|
||||
7 7 7
|
||||
8 8 8
|
||||
9 9 9
|
||||
5 5 5
|
||||
6 6 6
|
||||
7 7 7
|
||||
8 8 8
|
||||
9 9 9
|
||||
14 14
|
||||
12 12
|
||||
11 11
|
||||
10 10
|
||||
13 13
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5 5
|
||||
6 6 6
|
||||
7 7 7
|
||||
8 8 8
|
||||
9 9 9
|
||||
14 14
|
||||
12 12
|
||||
11 11
|
||||
10 10
|
||||
13 13
|
||||
5 5 5
|
||||
6 6 6
|
||||
7 7 7
|
||||
8 8 8
|
||||
9 9 9
|
||||
0 0 \N
|
||||
1 1 \N
|
||||
2 2 \N
|
||||
3 3 \N
|
||||
4 4 \N
|
||||
5 5 5
|
||||
6 6 6
|
||||
7 7 7
|
||||
8 8 8
|
||||
9 9 9
|
||||
5 5 5
|
||||
6 6 6
|
||||
7 7 7
|
||||
8 8 8
|
||||
9 9 9
|
||||
14 \N 14
|
||||
12 \N 12
|
||||
11 \N 11
|
||||
10 \N 10
|
||||
13 \N 13
|
||||
0 0 \N
|
||||
1 1 \N
|
||||
2 2 \N
|
||||
3 3 \N
|
||||
4 4 \N
|
||||
5 5 5
|
||||
6 6 6
|
||||
7 7 7
|
||||
8 8 8
|
||||
9 9 9
|
||||
14 \N 14
|
||||
12 \N 12
|
||||
11 \N 11
|
||||
10 \N 10
|
||||
13 \N 13
|
84
dbms/tests/queries/0_stateless/00444_join_use_nulls.sql
Normal file
84
dbms/tests/queries/0_stateless/00444_join_use_nulls.sql
Normal file
@ -0,0 +1,84 @@
|
||||
SET join_use_nulls = 0;
|
||||
|
||||
SELECT k, a, b
|
||||
FROM
|
||||
(
|
||||
SELECT number AS k, toString(number) AS a FROM system.numbers LIMIT 10
|
||||
)
|
||||
ANY INNER JOIN
|
||||
(
|
||||
SELECT number AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10
|
||||
) USING (k);
|
||||
|
||||
SELECT k, a, b
|
||||
FROM
|
||||
(
|
||||
SELECT number AS k, toString(number) AS a FROM system.numbers LIMIT 10
|
||||
)
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT number AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10
|
||||
) USING (k);
|
||||
|
||||
SELECT k, a, b
|
||||
FROM
|
||||
(
|
||||
SELECT number AS k, toString(number) AS a FROM system.numbers LIMIT 10
|
||||
)
|
||||
ANY RIGHT JOIN
|
||||
(
|
||||
SELECT number AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10
|
||||
) USING (k);
|
||||
|
||||
SELECT k, a, b
|
||||
FROM
|
||||
(
|
||||
SELECT number AS k, toString(number) AS a FROM system.numbers LIMIT 10
|
||||
)
|
||||
ANY FULL JOIN
|
||||
(
|
||||
SELECT number AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10
|
||||
) USING (k);
|
||||
|
||||
|
||||
SET join_use_nulls = 1;
|
||||
|
||||
SELECT k, a, b
|
||||
FROM
|
||||
(
|
||||
SELECT number AS k, toString(number) AS a FROM system.numbers LIMIT 10
|
||||
)
|
||||
ANY INNER JOIN
|
||||
(
|
||||
SELECT number AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10
|
||||
) USING (k);
|
||||
|
||||
SELECT k, a, b
|
||||
FROM
|
||||
(
|
||||
SELECT number AS k, toString(number) AS a FROM system.numbers LIMIT 10
|
||||
)
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT number AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10
|
||||
) USING (k);
|
||||
|
||||
SELECT k, a, b
|
||||
FROM
|
||||
(
|
||||
SELECT number AS k, toString(number) AS a FROM system.numbers LIMIT 10
|
||||
)
|
||||
ANY RIGHT JOIN
|
||||
(
|
||||
SELECT number AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10
|
||||
) USING (k);
|
||||
|
||||
SELECT k, a, b
|
||||
FROM
|
||||
(
|
||||
SELECT number AS k, toString(number) AS a FROM system.numbers LIMIT 10
|
||||
)
|
||||
ANY FULL JOIN
|
||||
(
|
||||
SELECT number AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10
|
||||
) USING (k);
|
Loading…
Reference in New Issue
Block a user