dbms: fixed error with arrays; added test [#METR-17110].

This commit is contained in:
Alexey Milovidov 2015-07-06 23:25:50 +03:00
parent 0296dc2b88
commit bbdfd33f47
3 changed files with 24 additions and 9 deletions

View File

@ -298,16 +298,14 @@ ColumnPtr ColumnArray::replicateConst(const Offsets_t & replicate_offsets) const
if (col_size != replicate_offsets.size())
throw Exception("Size of offsets doesn't match size of column.", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH);
ColumnPtr res = cloneEmpty();
if (0 == col_size)
return res;
ColumnArray & res_ = typeid_cast<ColumnArray &>(*res);
return cloneEmpty();
const Offsets_t & cur_offsets = getOffsets();
Offsets_t & res_offsets = res_.getOffsets();
ColumnOffsets_t * res_column_offsets = new ColumnOffsets_t;
ColumnPtr res_column_offsets_holder = res_column_offsets;
Offsets_t & res_offsets = res_column_offsets->getData();
res_offsets.reserve(replicate_offsets.back());
Offset_t prev_replicate_offset = 0;
@ -329,9 +327,7 @@ ColumnPtr ColumnArray::replicateConst(const Offsets_t & replicate_offsets) const
prev_data_offset = cur_offsets[i];
}
res_.getDataPtr() = res_.getData().cloneResized(res_offsets.back());
return res;
return new ColumnArray(getData().cloneResized(current_new_offset), res_column_offsets_holder);
}

View File

@ -0,0 +1,8 @@
['']
---
---
0 ['hello']
---
---
0 []
---

View File

@ -0,0 +1,11 @@
SELECT arrayFilter(x -> notEmpty(concat(x, 'hello')), ['']) ARRAY JOIN [0] AS elem, arrayMap(x -> concat(x, 'hello'), ['']) AS unused WHERE NOT ignore(elem);
SELECT '---';
SELECT arrayFilter(x -> x = 'hello', ['']) ARRAY JOIN [0] AS elem WHERE NOT ignore(elem) AND arrayExists(x -> x = 'hello', ['']);
SELECT '---';
SELECT arrayJoin([0]), replicate('hello', [1]) WHERE NOT ignore(replicate('hello', [1]));
SELECT '---';
SELECT arrayJoin([0]), replicate('hello', emptyArrayString()) ARRAY JOIN emptyArrayString() AS unused WHERE NOT ignore(replicate('hello', emptyArrayString()));
SELECT '---';
SELECT arrayJoin([0]), replicate('hello', emptyArrayString()) WHERE NOT ignore(replicate('hello', emptyArrayString()));
SELECT '---';
SELECT replicate('hello', emptyArrayString()) ARRAY JOIN emptyArrayString() AS unused WHERE NOT ignore(replicate('hello', emptyArrayString()));