mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
dbms: fixed error with creating Set from constant columns [#METR-2944].
This commit is contained in:
parent
97bba68642
commit
d9e96ed74e
@ -170,11 +170,20 @@ bool Set::insertFromBlock(const Block & block, bool create_ordered_set)
|
||||
ConstColumnPlainPtrs key_columns(keys_size);
|
||||
data_types.resize(keys_size);
|
||||
|
||||
/// Константные столбцы справа от IN поддерживается не напрямую. Для этого, они сначала материализуется.
|
||||
Columns materialized_columns;
|
||||
|
||||
/// Запоминаем столбцы, с которыми будем работать
|
||||
for (size_t i = 0; i < keys_size; ++i)
|
||||
{
|
||||
key_columns[i] = block.getByPosition(i).column;
|
||||
data_types[i] = block.getByPosition(i).type;
|
||||
|
||||
if (key_columns[i]->isConst())
|
||||
{
|
||||
materialized_columns.emplace_back(static_cast<const IColumnConst *>(key_columns[i])->convertToFullColumn());
|
||||
key_columns[i] = materialized_columns.back().get();
|
||||
}
|
||||
}
|
||||
|
||||
size_t rows = block.rows();
|
||||
|
30
dbms/tests/queries/0_stateless/00137_in_constants.reference
Normal file
30
dbms/tests/queries/0_stateless/00137_in_constants.reference
Normal file
@ -0,0 +1,30 @@
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
31
dbms/tests/queries/0_stateless/00137_in_constants.sql
Normal file
31
dbms/tests/queries/0_stateless/00137_in_constants.sql
Normal file
@ -0,0 +1,31 @@
|
||||
SELECT 1 IN (SELECT 1);
|
||||
SELECT materialize(1) IN (SELECT 1);
|
||||
SELECT 1 IN (SELECT materialize(1));
|
||||
SELECT materialize(1) IN (SELECT materialize(1));
|
||||
SELECT (1, 2) IN (SELECT 1, 2);
|
||||
SELECT (1, materialize(2)) IN (SELECT 1, 2);
|
||||
SELECT (1, materialize(2)) IN (SELECT materialize(1), 2);
|
||||
SELECT (1, materialize(2), 'Hello') IN (SELECT materialize(1), 2, 'Hello');
|
||||
SELECT (1, materialize(2), materialize('Hello')) IN (SELECT materialize(1), 2, 'Hello');
|
||||
SELECT (1, materialize(2), materialize('Hello')) IN (SELECT materialize(1), 2, materialize('Hello'));
|
||||
SELECT (1, materialize(2), 'Hello') IN (SELECT materialize(1), 2, materialize('Hello'));
|
||||
SELECT 'Hello' IN (SELECT 'Hello');
|
||||
SELECT materialize('Hello') IN (SELECT 'Hello');
|
||||
SELECT 'Hello' IN (SELECT materialize('Hello'));
|
||||
SELECT materialize('Hello') IN (SELECT materialize('Hello'));
|
||||
|
||||
SELECT 2 IN (SELECT 1);
|
||||
SELECT materialize(2) IN (SELECT 1);
|
||||
SELECT 2 IN (SELECT materialize(1));
|
||||
SELECT materialize(2) IN (SELECT materialize(1));
|
||||
SELECT (1, 3) IN (SELECT 1, 2);
|
||||
SELECT (1, materialize(3)) IN (SELECT 1, 2);
|
||||
SELECT (1, materialize(3)) IN (SELECT materialize(1), 2);
|
||||
SELECT (1, materialize(2), 'World') IN (SELECT materialize(1), 2, 'Hello');
|
||||
SELECT (1, materialize(2), materialize('World')) IN (SELECT materialize(1), 2, 'Hello');
|
||||
SELECT (1, materialize(2), materialize('World')) IN (SELECT materialize(1), 2, materialize('Hello'));
|
||||
SELECT (1, materialize(2), 'World') IN (SELECT materialize(1), 2, materialize('Hello'));
|
||||
SELECT 'World' IN (SELECT 'Hello');
|
||||
SELECT materialize('World') IN (SELECT 'Hello');
|
||||
SELECT 'World' IN (SELECT materialize('Hello'));
|
||||
SELECT materialize('World') IN (SELECT materialize('Hello'));
|
Loading…
Reference in New Issue
Block a user