Fix errors

This commit is contained in:
Alexey Milovidov 2021-01-05 04:26:29 +03:00
parent c378710f6b
commit a1ce6c4165
5 changed files with 18 additions and 13 deletions

View File

@ -96,6 +96,11 @@ public:
if constexpr (overflow)
{
if (value_type->onlyNull())
throw Exception{ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Cannot calculate {} of type {}",
getName(), value_type->getName()};
// Overflow, meaning that the returned type is the same as
// the input type. Nulls are skipped.
result_type = removeNullable(value_type);
@ -190,11 +195,8 @@ public:
{
// Create a value array for this key
Array new_values;
new_values.resize(values_types.size());
for (size_t k = 0; k < new_values.size(); ++k)
{
new_values[k] = (k == col) ? value : values_types[k]->getDefault();
}
new_values.resize(size);
new_values[col] = value;
if constexpr (IsDecimalNumber<T>)
{

View File

@ -1,7 +1,4 @@
([],[])
([],[])
([],[])
([2],[11])
([2],[22])
([1,2],[0,11])
([1,2],[0,22])
([2],[33])
([2],[33])

View File

@ -1,7 +1,7 @@
select minMap(arrayJoin([([1], [null]), ([1], [null])]));
select maxMap(arrayJoin([([1], [null]), ([1], [null])]));
select minMap(arrayJoin([([1], [null]), ([1], [null])])); -- { serverError 43 }
select maxMap(arrayJoin([([1], [null]), ([1], [null])])); -- { serverError 43 }
select sumMap(arrayJoin([([1], [null]), ([1], [null])])); -- { serverError 43 }
select sumMapWithOverflow(arrayJoin([([1], [null]), ([1], [null])]));
select sumMapWithOverflow(arrayJoin([([1], [null]), ([1], [null])])); -- { serverError 43 }
select minMap(arrayJoin([([1, 2], [null, 11]), ([1, 2], [null, 22])]));
select maxMap(arrayJoin([([1, 2], [null, 11]), ([1, 2], [null, 22])]));

View File

@ -0,0 +1 @@
([1,2],[1,2],[1,0])

View File

@ -0,0 +1,5 @@
select initializeAggregation('sumMap', [1, 2], [1, 2], [1, null]);
CREATE TEMPORARY TABLE sum_map_overflow (events Array(UInt8), counts Array(UInt8));
INSERT INTO sum_map_overflow VALUES ([1], [255]), ([1], [2]);
SELECT [NULL], sumMapWithOverflow(events, [NULL], [[(NULL)]], counts) FROM sum_map_overflow; -- { serverError 43 }