fix tests

This commit is contained in:
Nikita Mikhaylov 2021-07-07 10:39:16 +00:00
parent c4b0d8f849
commit 356c11bb25
17 changed files with 120 additions and 308 deletions

View File

@ -48,40 +48,22 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size(); for (size_t index = 0; index < getNumberOfArguments(); ++index)
{
const auto * arg = arguments[index].get();
if (number_of_arguments != 3) { if (index == 1 && !WhichDataType(arg).isFloat64())
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, throw Exception(
"Number of arguments for function {} doesn't match: passed {}, should be 3", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
getName(), "Illegal type {} of argument {} of function {}. Must be Float64",
toString(number_of_arguments)); arg->getName(), 2, getName());
} else if (!WhichDataType(arg).isUInt64()) {
throw Exception(
const auto * arg = arguments[0].get(); ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
if (!WhichDataType(arg).isUInt64()) { arg->getName(), index + 1, getName()
throw Exception( );
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, }
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 1, getName());
}
arg = arguments[1].get();
if (!WhichDataType(arg).isFloat64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be Float64",
arg->getName(), 2, getName());
}
arg = arguments[2].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 3, getName());
} }
return std::make_shared<DataTypeUInt8>(); return std::make_shared<DataTypeUInt8>();

View File

@ -50,44 +50,22 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size(); for (size_t index = 0; index < getNumberOfArguments(); ++index)
{
if (number_of_arguments != 4) { const auto * arg = arguments[index].get();
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " if ((index == 1 || index == 3) && !WhichDataType(arg).isFloat64())
+ toString(number_of_arguments) + ", should be 4", throw Exception(
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT
} "Illegal type {} of argument {} of function {}. Must be Float64",
arg->getName(), index + 1, getName()
const auto * arg = arguments[0].get(); );
else if (!WhichDataType(arg).isUInt64()) {
if (!WhichDataType(arg).isUInt64()) { throw Exception(
throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type " + arg->getName() + " of argument " + std::to_string(1) + " of function " + getName() + ". Must be UInt64", "Illegal type {} of argument {} of function {}. Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); arg->getName(), index + 1, getName()
} );
}
arg = arguments[1].get();
if (!WhichDataType(arg).isFloat64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " of function " + getName() + ". Must be Float64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
arg = arguments[2].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(3) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
arg = arguments[3].get();
if (!WhichDataType(arg).isFloat64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(4) + " of function " + getName() + ". Must be Float64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
} }
DataTypePtr center = std::make_shared<DataTypeUInt64>(); DataTypePtr center = std::make_shared<DataTypeUInt64>();

View File

@ -44,34 +44,22 @@ public:
return name; return name;
} }
size_t getNumberOfArguments() const override { return 1; } size_t getNumberOfArguments() const override { return 2; }
bool useDefaultImplementationForConstants() const override { return true; } bool useDefaultImplementationForConstants() const override { return true; }
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size(); for (size_t i = 0; i < getNumberOfArguments(); ++i)
{
if (number_of_arguments != 2) { const auto * arg = arguments[i].get();
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " if (!WhichDataType(arg).isUInt64()) {
+ toString(number_of_arguments) + ", should be 2", throw Exception(
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
} "Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), i, getName()
const auto * arg = arguments[0].get(); );
}
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(1) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
arg = arguments[1].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
} }
return std::make_shared<DataTypeUInt8>(); return std::make_shared<DataTypeUInt8>();

View File

@ -48,20 +48,14 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size();
if (number_of_arguments != 1) {
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
+ toString(number_of_arguments) + ", should be 2",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
}
const auto * arg = arguments[0].get(); const auto * arg = arguments[0].get();
if (!WhichDataType(arg).isUInt64()) { if (!WhichDataType(arg).isUInt64()) {
throw Exception( throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(1) + " of function " + getName() + ". Must be Float64", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); "Illegal type {} of argument {} of function {}. Must be Float64",
arg->getName(), 1, getName()
);
} }
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>()); return std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>());

View File

@ -50,36 +50,16 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size(); for (size_t index = 0; index < getNumberOfArguments(); ++index)
{
if (number_of_arguments != 3) { const auto * arg = arguments[index].get();
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " if (!WhichDataType(arg).isUInt64()) {
+ toString(number_of_arguments) + ", should be 3", throw Exception(
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
} "Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), i, getName()
const auto * arg = arguments[0].get(); );
}
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(1) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
arg = arguments[1].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
arg = arguments[2].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(3) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
} }
DataTypePtr element = std::make_shared<DataTypeUInt64>(); DataTypePtr element = std::make_shared<DataTypeUInt64>();

View File

@ -50,36 +50,16 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size(); for (size_t i = 0; i < getNumberOfArguments(); ++i)
{
if (number_of_arguments != 3) { const auto * arg = arguments[i].get();
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " if (!WhichDataType(arg).isUInt64()) {
+ toString(number_of_arguments) + ", should be 3", throw Exception(
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
} "Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), i, getName()
const auto * arg = arguments[0].get(); );
}
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(1) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
arg = arguments[1].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
arg = arguments[2].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(3) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
} }
return std::make_shared<DataTypeUInt8>(); return std::make_shared<DataTypeUInt8>();

View File

@ -50,49 +50,16 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size(); for (size_t i = 0; i < getNumberOfArguments(); ++i)
{
if (number_of_arguments != 4) { const auto * arg = arguments[i].get();
throw Exception( if (!WhichDataType(arg).isUInt64()) {
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, throw Exception(
"Number of arguments for function {} doesn't match: passed {}, should be 4", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
getName(), number_of_arguments); "Illegal type {} of argument {} of function {}. Must be UInt64",
} arg->getName(), i, getName()
);
const auto * arg = arguments[0].get(); }
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 1, getName());
}
arg = arguments[1].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 2, getName());
}
arg = arguments[2].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 3, getName());
}
arg = arguments[3].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 4, getName());
} }
DataTypePtr element = std::make_shared<DataTypeUInt64>(); DataTypePtr element = std::make_shared<DataTypeUInt64>();

View File

@ -50,49 +50,16 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size(); for (size_t i = 0; i < getNumberOfArguments(); ++i)
{
if (number_of_arguments != 4) { const auto * arg = arguments[i].get();
throw Exception( if (!WhichDataType(arg).isUInt64()) {
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, throw Exception(
"Number of arguments for function {} doesn't match: passed {}, should be 4", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
getName(), number_of_arguments); "Illegal type {} of argument {} of function {}. Must be UInt64",
} arg->getName(), i, getName()
);
const auto * arg = arguments[0].get(); }
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 1, getName());
}
arg = arguments[1].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 2, getName());
}
arg = arguments[2].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 3, getName());
}
arg = arguments[3].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 4, getName());
} }
DataTypePtr element = std::make_shared<DataTypeUInt64>(); DataTypePtr element = std::make_shared<DataTypeUInt64>();

View File

@ -48,27 +48,16 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size(); for (size_t i = 0; i < getNumberOfArguments(); ++i)
{
if (number_of_arguments != 2) { const auto * arg = arguments[i].get();
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " if (!WhichDataType(arg).isFloat64()) {
+ toString(number_of_arguments) + ", should be 2", throw Exception(
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
} "Illegal type {} of argument {} of function {}. Must be Float64",
arg->getName(), i, getName()
const auto * arg = arguments[0].get(); );
}
if (!WhichDataType(arg).isFloat64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(1) + " of function " + getName() + ". Must be Float64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
arg = arguments[1].get();
if (!WhichDataType(arg).isFloat64()) {
throw Exception(
"Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " of function " + getName() + ". Must be Float64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
} }
return std::make_shared<DataTypeUInt64>(); return std::make_shared<DataTypeUInt64>();

View File

@ -48,30 +48,16 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
size_t number_of_arguments = arguments.size(); for (size_t i = 0; i < getNumberOfArguments(); ++i)
{
if (number_of_arguments != 2) { const auto * arg = arguments[i].get();
throw Exception( if (!WhichDataType(arg).isFloat64()) {
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, throw Exception(
"Number of arguments for function {} doesn't match: passed {}, should be 2", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
getName(), number_of_arguments); "Illegal type {} of argument {} of function {}. Must be Float64",
} arg->getName(), i, getName()
);
const auto * arg = arguments[0].get(); }
if (!WhichDataType(arg).isFloat64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be Float64",
arg->getName(), 1, getName());
}
arg = arguments[1].get();
if (!WhichDataType(arg).isFloat64()) {
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be Float64",
arg->getName(), 2, getName());
} }
return std::make_shared<DataTypeUInt64>(); return std::make_shared<DataTypeUInt64>();

View File

@ -1,4 +1,4 @@
select degreesToS2(55.77922738, 37.63098076); select degreesToS2(55.77922738, 37.63098076);
select degreesToS2(55.76324100, 37.66018300); select degreesToS2(55.76324100, 37.66018300);
select degreesToS2(90, 45); select degreesToS2(90.0, 45.0);
select degreesToS2(-12, 34); select degreesToS2(-12.0, 34.0);

View File

@ -1,4 +1,4 @@
select radiansToS2(0.97353117, 0.65678451) select radiansToS2(0.97353117, 0.65678451);
select radiansToS2(0.97325215, 0.65729419) select radiansToS2(0.97325215, 0.65729419);
select radiansToS2(1.57079632, 0.78539816) select radiansToS2(1.57079632, 0.78539816);
select radiansToS2(-0.20943951, 0.59341194) select radiansToS2(-0.20943951, 0.59341194);

View File

@ -1,2 +1,2 @@
select S2ToGeo(4573520603753570041) select S2ToGeo(4573520603753570041);
select S2ToGeo(4573517609713934091) select S2ToGeo(4573517609713934091);

View File

@ -0,0 +1 @@
[5074766987100422144,5074766712222515200,5074767536856236032,5074767261978329088]

View File

@ -1 +1 @@
select S2GetNeigbors(5074766849661468672) select S2GetNeighbors(5074766849661468672);

View File

@ -1,2 +1,2 @@
select S2CellsIntersect(9926595209846587392, 9926594385212866560) select S2CellsIntersect(9926595209846587392, 9926594385212866560);
select S2CellsIntersect(9926595209846587392, 9937259648002293760) select S2CellsIntersect(9926595209846587392, 9937259648002293760);

View File

@ -1,2 +1,2 @@
select S2CapContains(1157339245694594829, 1.0, 1157347770437378819) select S2CapContains(1157339245694594829, 1.0, 1157347770437378819);
select S2CapContains(1157339245694594829, 1.0, 1152921504606846977) select S2CapContains(1157339245694594829, 1.0, 1152921504606846977);