diff --git a/src/Functions/S2CapContains.cpp b/src/Functions/S2CapContains.cpp index f93c14b41f8..53a5bc0197a 100644 --- a/src/Functions/S2CapContains.cpp +++ b/src/Functions/S2CapContains.cpp @@ -52,11 +52,14 @@ public: { const auto * arg = arguments[index].get(); - if (index == 1 && !WhichDataType(arg).isFloat64()) - throw Exception( - ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, - "Illegal type {} of argument {} of function {}. Must be Float64", - arg->getName(), 2, getName()); + if (index == 1) + { + if (!WhichDataType(arg).isFloat64()) + throw Exception( + ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, + "Illegal type {} of argument {} of function {}. Must be Float64", + arg->getName(), 2, getName()); + } else if (!WhichDataType(arg).isUInt64()) { throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, diff --git a/src/Functions/S2GetNeighbors.cpp b/src/Functions/S2GetNeighbors.cpp index ae77bffc812..8c5d87a1681 100644 --- a/src/Functions/S2GetNeighbors.cpp +++ b/src/Functions/S2GetNeighbors.cpp @@ -80,10 +80,10 @@ public: cell_id.GetEdgeNeighbors(neighbors); dst_data.reserve(dst_data.size() + 4); - for (int i = 0; i < 4; ++i) + for (auto & neighbor : neighbors) { ++current_offset; - dst_data.insert(neighbors[i].id()); + dst_data.insert(neighbor.id()); } dst_offsets[row] = current_offset; } diff --git a/src/Functions/S2ToGeo.cpp b/src/Functions/S2ToGeo.cpp index 2c761de218d..ddff9c3f52b 100644 --- a/src/Functions/S2ToGeo.cpp +++ b/src/Functions/S2ToGeo.cpp @@ -68,7 +68,7 @@ public: arg->getName(), 1, getName()); } - DataTypePtr element = std::make_shared(); + DataTypePtr element = std::make_shared(); return std::make_shared(DataTypes{element, element}); } @@ -77,14 +77,14 @@ public: { const auto * col_id = arguments[0].column.get(); - auto col_res_first = ColumnUInt32::create(); - auto col_res_second = ColumnUInt32::create(); + auto col_res_first = ColumnFloat64::create(); + auto col_res_second = ColumnFloat64::create(); auto & vec_res_first = col_res_first->getData(); - vec_res_first.resize(input_rows_count); + vec_res_first.reserve(input_rows_count); auto & vec_res_second = col_res_second->getData(); - vec_res_second.resize(input_rows_count); + vec_res_second.reserve(input_rows_count); for (const auto row : collections::range(0, input_rows_count)) { @@ -94,8 +94,8 @@ public: S2Point point = cell_id.ToPoint(); S2LatLng ll(point); - vec_res_first[row] = ll.lng().degrees(); - vec_res_second[row] = ll.lat().degrees(); + vec_res_first.emplace_back(ll.lng().degrees()); + vec_res_second.emplace_back(ll.lat().degrees()); } return ColumnTuple::create(Columns{std::move(col_res_first), std::move(col_res_second)}); diff --git a/src/Functions/radiansToS2.cpp b/src/Functions/radiansToS2.cpp index fbfe4cbad2f..67e1e9ab265 100644 --- a/src/Functions/radiansToS2.cpp +++ b/src/Functions/radiansToS2.cpp @@ -75,12 +75,9 @@ public: for (const auto row : collections::range(0, input_rows_count)) { const double lon = col_lon->getFloat64(row); - double lat = col_lat->getFloat64(row); + const double lat = col_lat->getFloat64(row); - lat = lon; - - S2LatLng lat_lng = S2LatLng::FromRadians(lat, lon); - S2CellId id(lat_lng); + S2CellId id(S2LatLng::FromRadians(lat, lon)); dst_data[row] = id.id(); } diff --git a/tests/queries/0_stateless/01851_s2_to_geo.reference b/tests/queries/0_stateless/01851_s2_to_geo.reference index d70646071c4..75b182ebd1f 100644 --- a/tests/queries/0_stateless/01851_s2_to_geo.reference +++ b/tests/queries/0_stateless/01851_s2_to_geo.reference @@ -1,4 +1,2 @@ -(55.7792274, 37.6309808) -(55.7632410, 37.6601830) -(90.0000000, 45.0000000) -(34.0000000, -12.0000000) +(55.779227241803866,37.63098046233757) +(55.76324102676383,37.660183005258276)