Fixed errors with tuples [#METR-18149].

This commit is contained in:
Alexey Milovidov 2016-07-10 07:09:59 +03:00
parent 9208a72b5a
commit 402a4933e3
4 changed files with 60 additions and 5 deletions

View File

@ -332,8 +332,8 @@ public:
for (size_t j = 0; j < num_elements; ++j)
out_data.insertFrom(*columns[j], i);
out_offsets[i] = current_offset;
current_offset += num_elements;
out_offsets[i] = current_offset;
}
block.getByPosition(result).column = out;

View File

@ -116,11 +116,18 @@ ColumnPtr ColumnConst<Tuple>::convertToFullColumn() const
if (!type)
throw Exception("Non-Tuple data type specified for ColumnConstTuple", ErrorCodes::LOGICAL_ERROR);
/// Ask data_type to create ColumnTuple of corresponding type
ColumnPtr res = type->createColumn();
static_cast<ColumnTuple &>(*res).insert(getDataFromHolderImpl());
/// Create columns for each element and convert to full columns.
const DataTypes & element_types = type->getElements();
size_t tuple_size = element_types.size();
Block block;
return res;
for (size_t i = 0; i < tuple_size; ++i)
block.insert(ColumnWithTypeAndName{
element_types[i]->createConstColumn(s, static_cast<const TupleBackend &>(*data)[i])->convertToFullColumnIfConst(),
element_types[i],
""});
return std::make_shared<ColumnTuple>(block);
}
void ColumnConst<Tuple>::getExtremes(Field & min, Field & max) const

View File

@ -0,0 +1,18 @@
('1',2) 1 2
('1',2) 1 2
('1',2) 1 2
('1',2) 1 2
('1',2) 1 2
[('1',2)] 1 2
[('1',2)] 1 2
[('1',2)] 1 2
[('1',2)] 1 2
[('1',2)] 1 2
[('1',2)] 1 2
[((1,'2'),[(3,[4])])] ((1,'2'),[(3,[4])]) (1,'2') [(3,[4])] 1 2 (3,[4]) 3 [4] 4
[('1',4)]
[('1',4)]
[('1',4)]
[('1',4)]
[('1',4)]
[('1',4)]

View File

@ -0,0 +1,30 @@
SELECT ('1',2) AS t, t.1, t.2;
SELECT materialize(('1',2)) AS t, t.1, t.2;
SELECT (materialize('1'),2) AS t, t.1, t.2;
SELECT ('1',materialize(2)) AS t, t.1, t.2;
SELECT (materialize('1'),materialize(2)) AS t, t.1, t.2;
SELECT [('1',2)] AS t, t[1].1, t[1].2;
SELECT [materialize(('1',2))] AS t, t[1].1, t[1].2;
SELECT [(materialize('1'),2)] AS t, t[1].1, t[1].2;
SELECT [('1',materialize(2))] AS t, t[1].1, t[1].2;
SELECT [(materialize('1'),materialize(2))] AS t, t[1].1, t[1].2;
SELECT materialize([('1',2)]) AS t, t[1].1, t[1].2;
SELECT [((1, materialize('2')), [(3, [4])])] AS thing,
thing[1],
thing[1].1,
thing[1].2,
thing[1].1.1,
thing[1].1.2,
(thing[1].2)[1],
(thing[1].2)[1].1,
(thing[1].2)[1].2,
((thing[1].2)[1].2)[1];
select arrayMap(t->tuple(t.1, t.2*2), [('1',2)]);
select arrayMap(t->tuple(t.1, t.2*2), [materialize(('1',2))]);
select arrayMap(t->tuple(t.1, t.2*2), [(materialize('1'),2)]);
select arrayMap(t->tuple(t.1, t.2*2), [('1',materialize(2))]);
select arrayMap(t->tuple(t.1, t.2*2), [(materialize('1'),materialize(2))]);
select arrayMap(t->tuple(t.1, t.2*2), materialize([('1',2)]));