mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fixed "join_use_nulls" mode #1544
This commit is contained in:
parent
671b731c90
commit
a71b04e377
@ -51,7 +51,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
ARRAY_JOIN,
|
ARRAY_JOIN,
|
||||||
|
|
||||||
/// INNER|LEFT JOIN.
|
|
||||||
JOIN,
|
JOIN,
|
||||||
|
|
||||||
/// Reorder and rename the columns, delete the extra ones. The same column names are allowed in the result.
|
/// Reorder and rename the columns, delete the extra ones. The same column names are allowed in the result.
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <DataTypes/DataTypeSet.h>
|
#include <DataTypes/DataTypeSet.h>
|
||||||
#include <DataTypes/DataTypeArray.h>
|
#include <DataTypes/DataTypeArray.h>
|
||||||
|
#include <DataTypes/DataTypeNullable.h>
|
||||||
#include <DataTypes/DataTypeTuple.h>
|
#include <DataTypes/DataTypeTuple.h>
|
||||||
#include <DataTypes/DataTypeExpression.h>
|
#include <DataTypes/DataTypeExpression.h>
|
||||||
#include <DataTypes/DataTypeNested.h>
|
#include <DataTypes/DataTypeNested.h>
|
||||||
@ -2838,7 +2839,9 @@ void ExpressionAnalyzer::collectJoinedColumns(NameSet & joined_columns, NamesAnd
|
|||||||
&& !joined_columns.count(col.name)) /// Duplicate columns in the subquery for JOIN do not make sense.
|
&& !joined_columns.count(col.name)) /// Duplicate columns in the subquery for JOIN do not make sense.
|
||||||
{
|
{
|
||||||
joined_columns.insert(col.name);
|
joined_columns.insert(col.name);
|
||||||
joined_columns_name_type.emplace_back(col.name, col.type);
|
|
||||||
|
bool make_nullable = settings.join_use_nulls && (table_join.kind == ASTTableJoin::Kind::Left || table_join.kind == ASTTableJoin::Kind::Full);
|
||||||
|
joined_columns_name_type.emplace_back(col.name, make_nullable ? makeNullable(col.type) : col.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
0 0 \N
|
||||||
|
1 1 1
|
30
dbms/tests/queries/0_stateless/00549_join_use_nulls.sql
Normal file
30
dbms/tests/queries/0_stateless/00549_join_use_nulls.sql
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
SET join_use_nulls = 1;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS test.null;
|
||||||
|
CREATE TABLE test.null (k UInt64, a String, b Nullable(String)) ENGINE = Log;
|
||||||
|
|
||||||
|
INSERT INTO test.null SELECT
|
||||||
|
k,
|
||||||
|
a,
|
||||||
|
b
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
number AS k,
|
||||||
|
toString(number) AS a
|
||||||
|
FROM system.numbers
|
||||||
|
LIMIT 2
|
||||||
|
)
|
||||||
|
ANY LEFT JOIN
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
number AS k,
|
||||||
|
toString(number) AS b
|
||||||
|
FROM system.numbers
|
||||||
|
LIMIT 1, 2
|
||||||
|
) USING (k)
|
||||||
|
ORDER BY k ASC;
|
||||||
|
|
||||||
|
SELECT * FROM test.null ORDER BY k, a, b;
|
||||||
|
|
||||||
|
DROP TABLE test.null;
|
Loading…
Reference in New Issue
Block a user