mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #46995 from ClickHouse/function-range-allow-ipv4
Allow IPv4 in range()
This commit is contained in:
commit
7b9d54a2d9
@ -55,14 +55,19 @@ private:
|
||||
getName(), arguments.size());
|
||||
}
|
||||
|
||||
for (const auto & arg : arguments)
|
||||
DataTypes arg_types;
|
||||
for (size_t i = 0, size = arguments.size(); i < size; ++i)
|
||||
{
|
||||
if (!isInteger(arg))
|
||||
if (i < 2 && WhichDataType(arguments[i]).isIPv4())
|
||||
arg_types.emplace_back(std::make_shared<DataTypeUInt32>());
|
||||
else if (isInteger(arguments[i]))
|
||||
arg_types.push_back(arguments[i]);
|
||||
else
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument of function {}",
|
||||
arg->getName(), getName());
|
||||
arguments[i]->getName(), getName());
|
||||
}
|
||||
|
||||
DataTypePtr common_type = getLeastSupertype(arguments);
|
||||
DataTypePtr common_type = getLeastSupertype(arg_types);
|
||||
return std::make_shared<DataTypeArray>(common_type);
|
||||
}
|
||||
|
||||
|
3
tests/queries/0_stateless/02674_range_ipv4.reference
Normal file
3
tests/queries/0_stateless/02674_range_ipv4.reference
Normal file
@ -0,0 +1,3 @@
|
||||
[2887712768,2887712769,2887712770,2887712771,2887712772,2887712773,2887712774,2887712775,2887712776,2887712777]
|
||||
[2887712768,2887712769,2887712770,2887712771,2887712772,2887712773,2887712774,2887712775,2887712776,2887712777]
|
||||
[2887712768,2887712769,2887712770,2887712771,2887712772,2887712773,2887712774,2887712775,2887712776,2887712777]
|
3
tests/queries/0_stateless/02674_range_ipv4.sql
Normal file
3
tests/queries/0_stateless/02674_range_ipv4.sql
Normal file
@ -0,0 +1,3 @@
|
||||
SELECT range(toIPv4('172.31.0.0'), toIPv4('172.31.0.10'));
|
||||
SELECT range(2887712768, toIPv4('172.31.0.10'));
|
||||
SELECT range(toIPv4('172.31.0.0'), 2887712778);
|
Loading…
Reference in New Issue
Block a user