diff --git a/src/Functions/geoToS2.cpp b/src/Functions/geoToS2.cpp index 8114092d684..1458a5d9eb0 100644 --- a/src/Functions/geoToS2.cpp +++ b/src/Functions/geoToS2.cpp @@ -55,12 +55,11 @@ public: for (size_t i = 0; i < getNumberOfArguments(); ++i) { const auto * arg = arguments[i].get(); - if (!WhichDataType(arg).isFloat64()) { + if (!WhichDataType(arg).isFloat64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be Float64", arg->getName(), i, getName()); - } } return std::make_shared(); diff --git a/src/Functions/s2CapContains.cpp b/src/Functions/s2CapContains.cpp index 0c5b2776402..159e8419436 100644 --- a/src/Functions/s2CapContains.cpp +++ b/src/Functions/s2CapContains.cpp @@ -21,7 +21,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } namespace @@ -71,12 +70,11 @@ public: "Illegal type {} of argument {} of function {}. Must be Float64", arg->getName(), 2, getName()); } - else if (!WhichDataType(arg).isUInt64()) { + else if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be UInt64", arg->getName(), index + 1, getName()); - } } return std::make_shared(); @@ -98,6 +96,12 @@ public: const Float64 degrees = col_degrees->getFloat64(row); const UInt64 point = col_point->getUInt(row); + if (isNaN(degrees)) + throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Radius of the cap must not be nan"); + + if (std::isinf(degrees)) + throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Radius of the cap must not be infinite"); + S1Angle angle = S1Angle::Degrees(degrees); S2Cap cap(S2CellId(center).ToPoint(), angle); diff --git a/src/Functions/s2CapUnion.cpp b/src/Functions/s2CapUnion.cpp index fc7305fa357..51a0873bf2a 100644 --- a/src/Functions/s2CapUnion.cpp +++ b/src/Functions/s2CapUnion.cpp @@ -23,7 +23,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } namespace @@ -67,13 +66,12 @@ public: "Illegal type {} of argument {} of function {}. Must be Float64", arg->getName(), index + 1, getName()); } - else if (!WhichDataType(arg).isUInt64()) { + else if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be UInt64", arg->getName(), index + 1, getName() ); - } } DataTypePtr center = std::make_shared(); @@ -89,14 +87,14 @@ public: const auto * col_center2 = arguments[2].column.get(); const auto * col_radius2 = arguments[3].column.get(); - auto col_res_first = ColumnUInt64::create(); - auto col_res_second = ColumnFloat64::create(); + auto col_res_center = ColumnUInt64::create(); + auto col_res_radius = ColumnFloat64::create(); - auto & vec_res_first = col_res_first->getData(); - vec_res_first.reserve(input_rows_count); + auto & vec_res_center = col_res_center->getData(); + vec_res_center.reserve(input_rows_count); - auto & vec_res_second = col_res_second->getData(); - vec_res_second.reserve(input_rows_count); + auto & vec_res_radius = col_res_radius->getData(); + vec_res_radius.reserve(input_rows_count); for (const auto row : collections::range(0, input_rows_count)) { @@ -116,11 +114,11 @@ public: S2Cap cap_union = cap1.Union(cap2); - vec_res_first[row] = S2CellId(cap_union.center()).id(); - vec_res_second[row] = cap_union.GetRadius().degrees(); + vec_res_center.emplace_back(S2CellId(cap_union.center()).id()); + vec_res_radius.emplace_back(cap_union.GetRadius().degrees()); } - return ColumnTuple::create(Columns{std::move(col_res_first), std::move(col_res_second)}); + return ColumnTuple::create(Columns{std::move(col_res_center), std::move(col_res_radius)}); } }; diff --git a/src/Functions/s2CellsIntersect.cpp b/src/Functions/s2CellsIntersect.cpp index f2db22601cd..97aa3403023 100644 --- a/src/Functions/s2CellsIntersect.cpp +++ b/src/Functions/s2CellsIntersect.cpp @@ -22,7 +22,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } namespace @@ -55,12 +54,11 @@ public: for (size_t i = 0; i < getNumberOfArguments(); ++i) { const auto * arg = arguments[i].get(); - if (!WhichDataType(arg).isUInt64()) { + if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be UInt64", arg->getName(), i, getName()); - } } return std::make_shared(); diff --git a/src/Functions/s2GetNeighbors.cpp b/src/Functions/s2GetNeighbors.cpp index d3cd3eed9b7..1013a475177 100644 --- a/src/Functions/s2GetNeighbors.cpp +++ b/src/Functions/s2GetNeighbors.cpp @@ -20,7 +20,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } namespace @@ -53,12 +52,11 @@ public: { const auto * arg = arguments[0].get(); - if (!WhichDataType(arg).isUInt64()) { + if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be Float64", arg->getName(), 1, getName()); - } return std::make_shared(std::make_shared()); } diff --git a/src/Functions/s2RectAdd.cpp b/src/Functions/s2RectAdd.cpp index 3cddbb09618..872c2435c93 100644 --- a/src/Functions/s2RectAdd.cpp +++ b/src/Functions/s2RectAdd.cpp @@ -22,7 +22,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } namespace @@ -53,12 +52,11 @@ public: for (size_t index = 0; index < getNumberOfArguments(); ++index) { const auto * arg = arguments[index].get(); - if (!WhichDataType(arg).isUInt64()) { + if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be UInt64", arg->getName(), index, getName()); - } } DataTypePtr element = std::make_shared(); diff --git a/src/Functions/s2RectContains.cpp b/src/Functions/s2RectContains.cpp index be6f05930b4..5795e777de4 100644 --- a/src/Functions/s2RectContains.cpp +++ b/src/Functions/s2RectContains.cpp @@ -22,7 +22,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } namespace @@ -52,12 +51,11 @@ public: for (size_t i = 0; i < getNumberOfArguments(); ++i) { const auto * arg = arguments[i].get(); - if (!WhichDataType(arg).isUInt64()) { + if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be UInt64", arg->getName(), i, getName()); - } } return std::make_shared(); diff --git a/src/Functions/s2RectIntersection.cpp b/src/Functions/s2RectIntersection.cpp index fee964e0bf7..17f04333a07 100644 --- a/src/Functions/s2RectIntersection.cpp +++ b/src/Functions/s2RectIntersection.cpp @@ -22,7 +22,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } namespace @@ -53,12 +52,11 @@ public: for (size_t i = 0; i < getNumberOfArguments(); ++i) { const auto * arg = arguments[i].get(); - if (!WhichDataType(arg).isUInt64()) { + if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be UInt64", arg->getName(), i, getName()); - } } DataTypePtr element = std::make_shared(); diff --git a/src/Functions/s2RectUnion.cpp b/src/Functions/s2RectUnion.cpp index 4ca7f2195fd..c866c5573ec 100644 --- a/src/Functions/s2RectUnion.cpp +++ b/src/Functions/s2RectUnion.cpp @@ -22,7 +22,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } namespace @@ -53,12 +52,11 @@ public: for (size_t i = 0; i < getNumberOfArguments(); ++i) { const auto * arg = arguments[i].get(); - if (!WhichDataType(arg).isUInt64()) { + if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be UInt64", arg->getName(), i + 1, getName()); - } } DataTypePtr element = std::make_shared(); diff --git a/src/Functions/s2ToGeo.cpp b/src/Functions/s2ToGeo.cpp index b32cf12454d..bf0608b2808 100644 --- a/src/Functions/s2ToGeo.cpp +++ b/src/Functions/s2ToGeo.cpp @@ -22,7 +22,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } namespace @@ -54,12 +53,11 @@ public: { const auto * arg = arguments[0].get(); - if (!WhichDataType(arg).isUInt64()) { + if (!WhichDataType(arg).isUInt64()) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument {} of function {}. Must be Float64", arg->getName(), 1, getName()); - } DataTypePtr element = std::make_shared(); diff --git a/tests/queries/0_stateless/01851_s2_to_geo.sql b/tests/queries/0_stateless/01851_s2_to_geo.sql index 4a6a4cdddab..76e4b2a5346 100644 --- a/tests/queries/0_stateless/01851_s2_to_geo.sql +++ b/tests/queries/0_stateless/01851_s2_to_geo.sql @@ -1,2 +1,2 @@ -select S2ToGeo(4573520603753570041); -select S2ToGeo(4573517609713934091); +select s2ToGeo(4573520603753570041); +select s2ToGeo(4573517609713934091); diff --git a/tests/queries/0_stateless/01852_s2_get_neighbours.sql b/tests/queries/0_stateless/01852_s2_get_neighbours.sql index 73be4393b2c..8163f827697 100644 --- a/tests/queries/0_stateless/01852_s2_get_neighbours.sql +++ b/tests/queries/0_stateless/01852_s2_get_neighbours.sql @@ -1 +1 @@ -select S2GetNeighbors(5074766849661468672); +select s2GetNeighbors(5074766849661468672);