Do not increment counter in system.errors when bitmapTransform is used

This commit is contained in:
Dmitry Novik 2024-11-15 12:28:49 +01:00 committed by Max Kainov
parent f29d7841fe
commit 540e9bc893
3 changed files with 27 additions and 9 deletions

View File

@ -512,17 +512,25 @@ public:
for (size_t i = 0; i < 2; ++i)
{
const auto * array_type = typeid_cast<const DataTypeArray *>(arguments[i + 1].get());
auto exception = Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "The second and third arguments for function {} "
"must be an one of [Array(UInt8), Array(UInt16), Array(UInt32), Array(UInt64)] "
"but one of them has type {}.", getName(), arguments[i + 1]->getName());
if (!array_type)
throw exception; /// NOLINT
bool has_error = false;
if (array_type)
{
auto nested_type = array_type->getNestedType();
WhichDataType which(nested_type);
if (!(which.isUInt8() || which.isUInt16() || which.isUInt32() || which.isUInt64()))
has_error = true;
}
else
{
has_error = true;
}
auto nested_type = array_type->getNestedType();
WhichDataType which(nested_type);
if (!(which.isUInt8() || which.isUInt16() || which.isUInt32() || which.isUInt64()))
throw exception; /// NOLINT
if (has_error)
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"The second and third arguments for function {} "
"must be an one of [Array(UInt8), Array(UInt16), Array(UInt32), Array(UInt64)] "
"but one of them has type {}.", getName(), arguments[i + 1]->getName());
}
return arguments[0];
}

View File

@ -0,0 +1,9 @@
CREATE TABLE counters (value UInt64) ENGINE = MergeTree() ORDER BY value;
INSERT INTO counters SELECT sum(value) FROM system.errors WHERE name = 'ILLEGAL_TYPE_OF_ARGUMENT';
SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), cast([5,999,2] as Array(UInt32)), cast([2,888,20] as Array(UInt32)))) AS res;
INSERT INTO counters SELECT sum(value) FROM system.errors WHERE name = 'ILLEGAL_TYPE_OF_ARGUMENT';
SELECT (max(value) - min(value)) == 0 FROM counters;