This commit is contained in:
Nikita Mikhaylov 2021-07-06 17:10:53 +00:00
parent 926380e7a7
commit e0473be7d7
7 changed files with 73 additions and 45 deletions

1
.gitmodules vendored
View File

@ -234,4 +234,3 @@
[submodule "contrib/s2geometry"]
path = contrib/s2geometry
url = https://github.com/ClickHouse-Extras/s2geometry.git
branch = master

View File

@ -47,33 +47,37 @@ public:
size_t number_of_arguments = arguments.size();
if (number_of_arguments != 3) {
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
+ toString(number_of_arguments) + ", should be 3",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH,
"Number of arguments for function {} doesn't match: passed {}, should be 3",
getName(),
toString(number_of_arguments));
}
const auto * arg = arguments[0].get();
if (!WhichDataType(arg).isUInt64()) {
throw Exception(
fmt::format("Illegal type {} of argument {} of function {}. Must be UInt64", arg->getName(), 1, getName()),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
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(
"Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " 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(), 2, getName());
}
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);
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 3, getName());
}
return std::make_shared<DataTypeUInt8>();

View File

@ -1,4 +1,8 @@
#include "config_functions.h"
#if !defined(ARCADIA_BUILD)
# include "config_functions.h"
#endif
#if USE_S2_GEOMETRY
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnTuple.h>
@ -49,41 +53,46 @@ public:
size_t number_of_arguments = arguments.size();
if (number_of_arguments != 4) {
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
+ toString(number_of_arguments) + ", should be 4",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
throw Exception(
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH,
"Number of arguments for function {} doesn't match: passed {}, should be 4",
getName(), number_of_arguments);
}
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);
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(
"Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
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(
"Illegal type " + arg->getName() + " of argument " + std::to_string(3) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
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(
"Illegal type " + arg->getName() + " of argument " + std::to_string(4) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 4, getName());
}
DataTypePtr element = std::make_shared<DataTypeUInt64>();
@ -142,3 +151,5 @@ void registerFunctionS2RectIntersection(FunctionFactory & factory)
}
#endif

View File

@ -49,41 +49,46 @@ public:
size_t number_of_arguments = arguments.size();
if (number_of_arguments != 4) {
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
+ toString(number_of_arguments) + ", should be 4",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
throw Exception(
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH,
"Number of arguments for function {} doesn't match: passed {}, should be 4",
getName(), number_of_arguments);
}
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);
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(
"Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
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(
"Illegal type " + arg->getName() + " of argument " + std::to_string(3) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
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(
"Illegal type " + arg->getName() + " of argument " + std::to_string(4) + " of function " + getName() + ". Must be UInt64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be UInt64",
arg->getName(), 4, getName());
}
DataTypePtr element = std::make_shared<DataTypeUInt64>();

View File

@ -49,17 +49,19 @@ public:
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);
throw Exception(
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH,
"Number of arguments for function {} doesn't match: passed {}, should be 2",
getName(), number_of_arguments);
}
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 Float64",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of argument {} of function {}. Must be Float64",
arg->getName(), 1, getName());
}
DataTypePtr element = std::make_shared<DataTypeUInt64>();

View File

@ -47,24 +47,27 @@ public:
size_t number_of_arguments = arguments.size();
if (number_of_arguments != 2) {
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);
throw Exception(
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH,
"Number of arguments for function {} doesn't match: passed {}, should be 2",
getName(), number_of_arguments);
}
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);
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(
"Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " 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(), 2, getName());
}
return std::make_shared<DataTypeUInt64>();

View File

@ -42,6 +42,7 @@ void registerFunctionH3ToString(FunctionFactory &);
void registerFunctionH3HexAreaM2(FunctionFactory &);
#endif
#if USE_S2_GEOMETRY
void registerFunctionDegreesToS2(FunctionFactory &);
void registerFunctionRadiansToS2(FunctionFactory &);
void registerFunctionS2GetNeighbors(FunctionFactory &);
@ -53,6 +54,7 @@ void registerFunctionS2RectAdd(FunctionFactory &);
void registerFunctionS2RectContains(FunctionFactory &);
void registerFunctionS2RectUnion(FunctionFactory &);
void registerFunctionS2RectIntersection(FunctionFactory &);
#endif
void registerFunctionsGeo(FunctionFactory & factory)
@ -92,6 +94,7 @@ void registerFunctionsGeo(FunctionFactory & factory)
registerFunctionH3HexAreaM2(factory);
#endif
#if USE_S2_GEOMETRY
registerFunctionDegreesToS2(factory);
registerFunctionRadiansToS2(factory);
registerFunctionS2GetNeighbors(factory);
@ -103,6 +106,7 @@ void registerFunctionsGeo(FunctionFactory & factory)
registerFunctionS2RectContains(factory);
registerFunctionS2RectUnion(factory);
registerFunctionS2RectIntersection(factory);
#endif
}
}