mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix fuzzer
This commit is contained in:
parent
fa816ab19c
commit
1b4f60a0f6
@ -21,6 +21,7 @@ namespace DB
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -92,9 +93,9 @@ public:
|
||||
|
||||
for (const auto row : collections::range(0, input_rows_count))
|
||||
{
|
||||
const UInt64 center = col_center->getUInt(row);
|
||||
const auto center = S2CellId(col_center->getUInt(row));
|
||||
const Float64 degrees = col_degrees->getFloat64(row);
|
||||
const UInt64 point = col_point->getUInt(row);
|
||||
const auto point = S2CellId(col_point->getUInt(row));
|
||||
|
||||
if (isNaN(degrees))
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Radius of the cap must not be nan");
|
||||
@ -102,10 +103,16 @@ public:
|
||||
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);
|
||||
if (!center.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Center is not valid");
|
||||
|
||||
dst_data.emplace_back(cap.Contains(S2CellId(point).ToPoint()));
|
||||
if (!point.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Point is not valid");
|
||||
|
||||
S1Angle angle = S1Angle::Degrees(degrees);
|
||||
S2Cap cap(center.ToPoint(), angle);
|
||||
|
||||
dst_data.emplace_back(cap.Contains(point.ToPoint()));
|
||||
}
|
||||
|
||||
return dst;
|
||||
|
@ -15,14 +15,13 @@
|
||||
|
||||
#include "s2_fwd.h"
|
||||
|
||||
class S2CellId;
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -98,19 +97,25 @@ public:
|
||||
|
||||
for (const auto row : collections::range(0, input_rows_count))
|
||||
{
|
||||
const UInt64 center1 = col_center1->getUInt(row);
|
||||
const Float64 radius1 = col_radius1->getFloat64(row);
|
||||
const UInt64 center2 = col_center2->getUInt(row);
|
||||
const Float64 radius2 = col_radius2->getFloat64(row);
|
||||
const UInt64 first_center = col_center1->getUInt(row);
|
||||
const Float64 first_radius = col_radius1->getFloat64(row);
|
||||
const UInt64 second_center = col_center2->getUInt(row);
|
||||
const Float64 second_radius = col_radius2->getFloat64(row);
|
||||
|
||||
if (isNaN(radius1) || isNaN(radius2))
|
||||
if (isNaN(first_radius) || isNaN(second_radius))
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Radius of the cap must not be nan");
|
||||
|
||||
if (std::isinf(radius1) || std::isinf(radius2))
|
||||
if (std::isinf(first_radius) || std::isinf(second_radius))
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Radius of the cap must not be infinite");
|
||||
|
||||
S2Cap cap1(S2CellId(center1).ToPoint(), S1Angle::Degrees(radius1));
|
||||
S2Cap cap2(S2CellId(center2).ToPoint(), S1Angle::Degrees(radius2));
|
||||
auto first_center_cell = S2CellId(first_center);
|
||||
auto second_center_cell = S2CellId(second_center);
|
||||
|
||||
if (!first_center_cell.is_valid() || !second_center_cell.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Center of the cap is not valid");
|
||||
|
||||
S2Cap cap1(first_center_cell.ToPoint(), S1Angle::Degrees(first_radius));
|
||||
S2Cap cap2(second_center_cell.ToPoint(), S1Angle::Degrees(second_radius));
|
||||
|
||||
S2Cap cap_union = cap1.Union(cap2);
|
||||
|
||||
|
@ -14,14 +14,13 @@
|
||||
|
||||
#include "s2_fwd.h"
|
||||
|
||||
class S2CellId;
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -78,6 +77,12 @@ public:
|
||||
const UInt64 id_first = col_id_first->getInt(row);
|
||||
const UInt64 id_second = col_id_second->getInt(row);
|
||||
|
||||
auto first_cell = S2CellId(id_first);
|
||||
auto second_cell = S2CellId(id_second);
|
||||
|
||||
if (!first_cell.is_valid() || !second_cell.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Cell is not valid");
|
||||
|
||||
dst_data.emplace_back(S2CellId(id_first).intersects(S2CellId(id_second)));
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ namespace DB
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -76,6 +77,10 @@ public:
|
||||
const UInt64 id = col_id->getUInt(row);
|
||||
|
||||
S2CellId cell_id(id);
|
||||
|
||||
if (!cell_id.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Cell is not valid");
|
||||
|
||||
S2CellId neighbors[4];
|
||||
cell_id.GetEdgeNeighbors(neighbors);
|
||||
|
||||
|
@ -14,20 +14,18 @@
|
||||
|
||||
#include "s2_fwd.h"
|
||||
|
||||
class S2CellId;
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
||||
class FunctionS2RectAdd : public IFunction
|
||||
{
|
||||
public:
|
||||
@ -81,13 +79,19 @@ public:
|
||||
|
||||
for (const auto row : collections::range(0, input_rows_count))
|
||||
{
|
||||
const UInt64 lo = col_lo->getUInt(row);
|
||||
const UInt64 hi = col_hi->getUInt(row);
|
||||
const UInt64 point = col_point->getUInt(row);
|
||||
const auto lo = S2CellId(col_lo->getUInt(row));
|
||||
const auto hi = S2CellId(col_hi->getUInt(row));
|
||||
const auto point = S2CellId(col_point->getUInt(row));
|
||||
|
||||
S2LatLngRect rect(S2CellId(lo).ToLatLng(), S2CellId(hi).ToLatLng());
|
||||
if (!lo.is_valid() || !hi.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Rectangle is not valid");
|
||||
|
||||
rect.AddPoint(S2CellId(point).ToPoint());
|
||||
if (!point.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Point is not valid");
|
||||
|
||||
S2LatLngRect rect(lo.ToLatLng(), hi.ToLatLng());
|
||||
|
||||
rect.AddPoint(point.ToPoint());
|
||||
|
||||
vec_res_first.emplace_back(S2CellId(rect.lo()).id());
|
||||
vec_res_second.emplace_back(S2CellId(rect.hi()).id());
|
||||
|
@ -14,14 +14,13 @@
|
||||
|
||||
#include "s2_fwd.h"
|
||||
|
||||
class S2CellId;
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -69,21 +68,23 @@ public:
|
||||
|
||||
auto dst = ColumnVector<UInt8>::create();
|
||||
auto & dst_data = dst->getData();
|
||||
dst_data.resize(input_rows_count);
|
||||
dst_data.reserve(input_rows_count);
|
||||
|
||||
for (const auto row : collections::range(0, input_rows_count))
|
||||
{
|
||||
const UInt64 lo = col_lo->getUInt(row);
|
||||
const UInt64 hi = col_hi->getUInt(row);
|
||||
const UInt64 point = col_point->getUInt(row);
|
||||
const auto lo = S2CellId(col_lo->getUInt(row));
|
||||
const auto hi = S2CellId(col_hi->getUInt(row));
|
||||
const auto point = S2CellId(col_point->getUInt(row));
|
||||
|
||||
S2CellId id_lo(lo);
|
||||
S2CellId id_hi(hi);
|
||||
S2CellId id_point(point);
|
||||
if (!lo.is_valid() || !hi.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Rectangle is not valid");
|
||||
|
||||
S2LatLngRect rect(id_lo.ToLatLng(), id_hi.ToLatLng());
|
||||
if (!point.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Point is not valid");
|
||||
|
||||
dst_data[row] = rect.Contains(id_point.ToLatLng());
|
||||
S2LatLngRect rect(lo.ToLatLng(), hi.ToLatLng());
|
||||
|
||||
dst_data.emplace_back(rect.Contains(point.ToLatLng()));
|
||||
}
|
||||
|
||||
return dst;
|
||||
|
@ -22,6 +22,7 @@ namespace DB
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -31,7 +32,7 @@ namespace
|
||||
class FunctionS2RectIntersection : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "S2RectIntersection";
|
||||
static constexpr auto name = "s2RectIntersection";
|
||||
|
||||
static FunctionPtr create(ContextPtr)
|
||||
{
|
||||
@ -82,13 +83,19 @@ public:
|
||||
|
||||
for (const auto row : collections::range(0, input_rows_count))
|
||||
{
|
||||
const UInt64 lo1 = col_lo1->getUInt(row);
|
||||
const UInt64 hi1 = col_hi1->getUInt(row);
|
||||
const UInt64 lo2 = col_lo2->getUInt(row);
|
||||
const UInt64 hi2 = col_hi2->getUInt(row);
|
||||
const auto lo1 = S2CellId(col_lo1->getUInt(row));
|
||||
const auto hi1 = S2CellId(col_hi1->getUInt(row));
|
||||
const auto lo2 = S2CellId(col_lo2->getUInt(row));
|
||||
const auto hi2 = S2CellId(col_hi2->getUInt(row));
|
||||
|
||||
S2LatLngRect rect1(S2CellId(lo1).ToLatLng(), S2CellId(hi1).ToLatLng());
|
||||
S2LatLngRect rect2(S2CellId(lo2).ToLatLng(), S2CellId(hi2).ToLatLng());
|
||||
if (!lo1.is_valid() || !hi1.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "First rectangle is not valid");
|
||||
|
||||
if (!lo2.is_valid() || !hi2.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second rectangle is not valid");
|
||||
|
||||
S2LatLngRect rect1(lo1.ToLatLng(), hi1.ToLatLng());
|
||||
S2LatLngRect rect2(lo2.ToLatLng(), hi2.ToLatLng());
|
||||
|
||||
S2LatLngRect rect_intersection = rect1.Intersection(rect2);
|
||||
|
||||
|
@ -14,14 +14,13 @@
|
||||
|
||||
#include "s2_fwd.h"
|
||||
|
||||
class S2CellId;
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -31,7 +30,7 @@ namespace
|
||||
class FunctionS2RectUnion : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "S2RectUnion";
|
||||
static constexpr auto name = "s2RectUnion";
|
||||
|
||||
static FunctionPtr create(ContextPtr)
|
||||
{
|
||||
@ -82,13 +81,19 @@ public:
|
||||
|
||||
for (const auto row : collections::range(0, input_rows_count))
|
||||
{
|
||||
const UInt64 lo1 = col_lo1->getUInt(row);
|
||||
const UInt64 hi1 = col_hi1->getUInt(row);
|
||||
const UInt64 lo2 = col_lo2->getUInt(row);
|
||||
const UInt64 hi2 = col_hi2->getUInt(row);
|
||||
const auto lo1 = S2CellId(col_lo1->getUInt(row));
|
||||
const auto hi1 = S2CellId(col_hi1->getUInt(row));
|
||||
const auto lo2 = S2CellId(col_lo2->getUInt(row));
|
||||
const auto hi2 = S2CellId(col_hi2->getUInt(row));
|
||||
|
||||
S2LatLngRect rect1(S2CellId(lo1).ToLatLng(), S2CellId(hi1).ToLatLng());
|
||||
S2LatLngRect rect2(S2CellId(lo2).ToLatLng(), S2CellId(hi2).ToLatLng());
|
||||
if (!lo1.is_valid() || !hi1.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "First rectangle is not valid");
|
||||
|
||||
if (!lo2.is_valid() || !hi2.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second rectangle is not valid");
|
||||
|
||||
S2LatLngRect rect1(lo1.ToLatLng(), hi1.ToLatLng());
|
||||
S2LatLngRect rect2(lo2.ToLatLng(), hi2.ToLatLng());
|
||||
|
||||
S2LatLngRect rect_union = rect1.Union(rect2);
|
||||
|
||||
|
@ -22,6 +22,7 @@ namespace DB
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -79,9 +80,12 @@ public:
|
||||
|
||||
for (const auto row : collections::range(0, input_rows_count))
|
||||
{
|
||||
const UInt64 id = col_id->getUInt(row);
|
||||
const auto id = S2CellId(col_id->getUInt(row));
|
||||
|
||||
S2Point point = S2CellId(id).ToPoint();
|
||||
if (!id.is_valid())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Point is not valid");
|
||||
|
||||
S2Point point = id.ToPoint();
|
||||
S2LatLng ll(point);
|
||||
|
||||
longitude.emplace_back(ll.lng().degrees());
|
||||
|
@ -1,2 +1,5 @@
|
||||
select s2CellsIntersect(9926595209846587392, 9926594385212866560);
|
||||
select s2CellsIntersect(9926595209846587392, 9937259648002293760);
|
||||
|
||||
|
||||
SELECT s2CellsIntersect(9926595209846587392, 9223372036854775806); -- { serverError 36 }
|
||||
|
@ -1,5 +1,3 @@
|
||||
1
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
||||
|
@ -7,5 +7,5 @@ select s2CapContains(1157339245694594829, nan, 1157339245694594829); -- { server
|
||||
select s2CapContains(1157339245694594829, 3.14, nan); -- { serverError 43 }
|
||||
|
||||
|
||||
select s2CapContains(toUInt64(-1), -1.0, toUInt64(-1));
|
||||
select s2CapContains(toUInt64(-1), 9999.9999, toUInt64(-1));
|
||||
select s2CapContains(toUInt64(-1), -1.0, toUInt64(-1)); -- { serverError 36 }
|
||||
select s2CapContains(toUInt64(-1), 9999.9999, toUInt64(-1)); -- { serverError 36 }
|
||||
|
Loading…
Reference in New Issue
Block a user