Fix tests.

This commit is contained in:
Nikolai Kochetov 2019-02-12 13:09:03 +03:00
parent ec6a5590fd
commit a4441bfba2
3 changed files with 11 additions and 4 deletions

View File

@ -349,6 +349,11 @@ static void pushBackAndCreateState(ColumnAggregateFunction::Container & data, Ar
void ColumnAggregateFunction::insert(const Field & x)
{
String type_string = getTypeString();
if (x.getType() != Field::Types::AggregateFunctionState)
throw Exception(String("Inserting field of type ") + x.getTypeName() + " into ColumnAggregateFunction. "
"Expected " + Field::Types::toString(Field::Types::AggregateFunctionState), ErrorCodes::LOGICAL_ERROR);
auto & field_name = x.get<const AggregateFunctionStateData &>().name;
if (type_string != field_name)
throw Exception("Cannot insert filed with type " + field_name + " into column with type " + type_string,

View File

@ -264,7 +264,8 @@ MutableColumnPtr DataTypeAggregateFunction::createColumn() const
/// Create empty state
Field DataTypeAggregateFunction::getDefault() const
{
Field field = String();
Field field = AggregateFunctionStateData();
field.get<AggregateFunctionStateData &>().name = getName();
AlignedBuffer place_buffer(function->sizeOfData(), function->alignOfData());
AggregateDataPtr place = place_buffer.data();
@ -273,7 +274,7 @@ Field DataTypeAggregateFunction::getDefault() const
try
{
WriteBufferFromString buffer_from_field(field.get<String &>());
WriteBufferFromString buffer_from_field(field.get<AggregateFunctionStateData &>().data);
function->serialize(place, buffer_from_field);
}
catch (...)

View File

@ -5,4 +5,5 @@ SELECT toUInt64((SELECT 9)) IN (SELECT number FROM system.numbers LIMIT 10);
SELECT (SELECT toDate('2015-01-02')) = toDate('2015-01-02'), 'Hello' = (SELECT 'Hello');
SELECT (SELECT toDate('2015-01-02'), 'Hello');
SELECT (SELECT toDate('2015-01-02'), 'Hello') AS x, x, identity((SELECT 1)), identity((SELECT 1) AS y);
SELECT (SELECT uniqState('')); -- { serverError 125 }
-- SELECT (SELECT uniqState(''));