mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Fixed bug found by PVS-Studio; added test [#CLICKHOUSE-3]
This commit is contained in:
parent
47c24bb2ad
commit
f467fb38c7
@ -2585,7 +2585,7 @@ String FunctionArraySlice::getName() const
|
||||
|
||||
DataTypePtr FunctionArraySlice::getReturnTypeImpl(const DataTypes & arguments) const
|
||||
{
|
||||
size_t number_of_arguments = arguments.size();
|
||||
const size_t number_of_arguments = arguments.size();
|
||||
|
||||
if (number_of_arguments < 2 || number_of_arguments > 3)
|
||||
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
|
||||
@ -3320,7 +3320,7 @@ String FunctionArrayResize::getName() const
|
||||
|
||||
DataTypePtr FunctionArrayResize::getReturnTypeImpl(const DataTypes & arguments) const
|
||||
{
|
||||
size_t number_of_arguments = arguments.size();
|
||||
const size_t number_of_arguments = arguments.size();
|
||||
|
||||
if (number_of_arguments < 2 || number_of_arguments > 3)
|
||||
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
|
||||
@ -3343,9 +3343,9 @@ DataTypePtr FunctionArrayResize::getReturnTypeImpl(const DataTypes & arguments)
|
||||
"Argument " + toString(1) + " for function " + getName() + " must be integer but it has type "
|
||||
+ arguments[1]->getName() + ".", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
|
||||
if (number_of_arguments)
|
||||
if (number_of_arguments == 2)
|
||||
return arguments[0];
|
||||
else
|
||||
else /* if (number_of_arguments == 3) */
|
||||
return std::make_shared<DataTypeArray>(getLeastSupertype({array_type->getNestedType(), arguments[2]}));
|
||||
}
|
||||
|
||||
|
@ -11,3 +11,4 @@
|
||||
[[],[],[1,2],[3,4]]
|
||||
[[1,2],[3,4],[5,6],[5,6]]
|
||||
[[5,6],[5,6],[1,2],[3,4]]
|
||||
[1,2,3,423.56,423.56]
|
||||
|
@ -12,3 +12,5 @@ select arrayResize([[1, 2], [3, 4]], -4);
|
||||
select arrayResize([[1, 2], [3, 4]], 4, [5, 6]);
|
||||
select arrayResize([[1, 2], [3, 4]], -4, [5, 6]);
|
||||
|
||||
-- different types of array elements and default value to fill
|
||||
select arrayResize([1, 2, 3], 5, 423.56);
|
||||
|
Loading…
Reference in New Issue
Block a user