Merge pull request #71971 from ClickHouse/fix-error-counter-bitmapTransform

Do not increment counter in system.errors when bitmapTransform is used
This commit is contained in:
Dmitry Novik 2024-11-18 14:03:09 +00:00 committed by GitHub
commit d7f920d2cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 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,11 @@
-- Tags: no-parallel
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 FORMAT Null;
INSERT INTO counters SELECT sum(value) FROM system.errors WHERE name = 'ILLEGAL_TYPE_OF_ARGUMENT';
SELECT (max(value) - min(value)) == 0 FROM counters;