dbms: fixed error with creating Set from constant columns [#METR-2944].

This commit is contained in:
Alexey Milovidov 2015-03-15 10:56:46 +03:00
parent 97bba68642
commit d9e96ed74e
3 changed files with 70 additions and 0 deletions

View File

@ -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();

View 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

View 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'));