From a7427a9cdfc19893b2b3875da19cda3a027467b8 Mon Sep 17 00:00:00 2001 From: Nikita Mikhailov Date: Sat, 20 Feb 2021 20:44:18 +0300 Subject: [PATCH] better --- src/Functions/geometryConverters.h | 18 ++-- src/Functions/polygonArea.cpp | 23 +++-- src/Functions/polygonConvexHull.cpp | 4 +- src/Functions/polygonPerimeter.cpp | 19 ++++- src/Functions/polygonsDistance.cpp | 24 ++++-- src/Functions/polygonsEquals.cpp | 25 ++++-- src/Functions/polygonsIntersection.cpp | 36 +++++--- src/Functions/polygonsSymDifference.cpp | 31 ++++--- src/Functions/polygonsUnion.cpp | 37 +++++--- src/Functions/polygonsWithin.cpp | 27 ++++-- src/Functions/svg.cpp | 1 + src/Functions/wkt.cpp | 1 + tests/queries/0_stateless/01300_svg.reference | 84 +++++++++---------- tests/queries/0_stateless/01300_svg.sql | 48 +++++------ tests/queries/0_stateless/01300_wkt.reference | 8 +- tests/queries/0_stateless/01300_wkt.sql | 8 +- 16 files changed, 240 insertions(+), 154 deletions(-) diff --git a/src/Functions/geometryConverters.h b/src/Functions/geometryConverters.h index c6549cba40f..02d6fb2a039 100644 --- a/src/Functions/geometryConverters.h +++ b/src/Functions/geometryConverters.h @@ -75,12 +75,14 @@ template class PointFromColumnConverter { public: - explicit PointFromColumnConverter(ColumnPtr col_) : col(col_) { } - std::vector convert() const; + std::vector convert() const + { + return convertImpl(0, col->size()); + } private: std::vector convertImpl(size_t shift, size_t count) const; @@ -113,8 +115,6 @@ template class PolygonFromColumnConverter { public: - PolygonFromColumnConverter() = default; - explicit PolygonFromColumnConverter(ColumnPtr col_) : col(col_) , ring_converter(typeid_cast(*col_).getDataPtr()) @@ -135,8 +135,6 @@ template class MultiPolygonFromColumnConverter { public: - MultiPolygonFromColumnConverter() = default; - explicit MultiPolygonFromColumnConverter(ColumnPtr col_) : col(col_) , polygon_converter(typeid_cast(*col_).getDataPtr()) @@ -334,11 +332,13 @@ template static void callOnGeometryDataType(DataTypePtr type, F && f) { /// There is no Point type, because for most of geometry functions it is useless. - if (DataTypeCustomRingSerialization::nestedDataType()->equals(*type)) + if (DataTypeCustomPointSerialization::nestedDataType()->equals(*type)) + return f(ConverterType>()); + else if (DataTypeCustomRingSerialization::nestedDataType()->equals(*type)) return f(ConverterType>()); - if (DataTypeCustomPolygonSerialization::nestedDataType()->equals(*type)) + else if (DataTypeCustomPolygonSerialization::nestedDataType()->equals(*type)) return f(ConverterType>()); - if (DataTypeCustomMultiPolygonSerialization::nestedDataType()->equals(*type)) + else if (DataTypeCustomMultiPolygonSerialization::nestedDataType()->equals(*type)) return f(ConverterType>()); throw Exception(fmt::format("Unknown geometry type {}", type->getName()), ErrorCodes::BAD_ARGUMENTS); } diff --git a/src/Functions/polygonArea.cpp b/src/Functions/polygonArea.cpp index 1f2d47a3a5c..71ac0d27715 100644 --- a/src/Functions/polygonArea.cpp +++ b/src/Functions/polygonArea.cpp @@ -20,6 +20,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + template class FunctionPolygonArea : public IFunction { @@ -61,14 +66,20 @@ public: { using TypeConverter = std::decay_t; using Converter = typename TypeConverter::Type; - Converter converter(arguments[0].column->convertToFullColumnIfConst()); - auto geometries = converter.convert(); - auto & res_data = res_column->getData(); - res_data.reserve(input_rows_count); + if constexpr (std::is_same_v, Converter>) + throw Exception(fmt::format("The argument of function {} must not be Point", getName()), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + else + { + Converter converter(arguments[0].column->convertToFullColumnIfConst()); + auto geometries = converter.convert(); - for (size_t i = 0; i < input_rows_count; i++) - res_data.emplace_back(boost::geometry::area(geometries[i])); + auto & res_data = res_column->getData(); + res_data.reserve(input_rows_count); + + for (size_t i = 0; i < input_rows_count; i++) + res_data.emplace_back(boost::geometry::area(geometries[i])); + } } ); diff --git a/src/Functions/polygonConvexHull.cpp b/src/Functions/polygonConvexHull.cpp index 422e46b3b15..3181a1ae3b4 100644 --- a/src/Functions/polygonConvexHull.cpp +++ b/src/Functions/polygonConvexHull.cpp @@ -67,8 +67,8 @@ public: using TypeConverter = std::decay_t; using Converter = typename TypeConverter::Type; - if (std::is_same_v>) - throw Exception(fmt::format("The argument of function {} could not be a MultiPolygon", getName()), ErrorCodes::BAD_ARGUMENTS); + if constexpr (std::is_same_v>) + throw Exception(fmt::format("The argument of function {} must not be a Point", getName()), ErrorCodes::BAD_ARGUMENTS); else { Converter converter(arguments[0].column->convertToFullColumnIfConst()); diff --git a/src/Functions/polygonPerimeter.cpp b/src/Functions/polygonPerimeter.cpp index 1855ada51ed..fef0777ab52 100644 --- a/src/Functions/polygonPerimeter.cpp +++ b/src/Functions/polygonPerimeter.cpp @@ -19,6 +19,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + template class FunctionPolygonPerimeter : public IFunction @@ -63,11 +68,17 @@ public: { using TypeConverter = std::decay_t; using Converter = typename TypeConverter::Type; - Converter converter(arguments[0].column->convertToFullColumnIfConst()); - auto geometries = converter.convert(); - for (size_t i = 0; i < input_rows_count; i++) - res_data.emplace_back(boost::geometry::perimeter(geometries[i])); + if constexpr (std::is_same_v, Converter>) + throw Exception(fmt::format("The argument of function {} must not be Point", getName()), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + else + { + Converter converter(arguments[0].column->convertToFullColumnIfConst()); + auto geometries = converter.convert(); + + for (size_t i = 0; i < input_rows_count; i++) + res_data.emplace_back(boost::geometry::perimeter(geometries[i])); + } } ); diff --git a/src/Functions/polygonsDistance.cpp b/src/Functions/polygonsDistance.cpp index a5341482f2f..72b1d5bc888 100644 --- a/src/Functions/polygonsDistance.cpp +++ b/src/Functions/polygonsDistance.cpp @@ -22,6 +22,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + template class FunctionPolygonsDistance : public IFunction { @@ -69,15 +74,20 @@ public: using LeftConverter = typename LeftConverterType::Type; using RightConverter = typename RightConverterType::Type; - auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); - auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - - for (size_t i = 0; i < input_rows_count; i++) + if constexpr (std::is_same_v, LeftConverter> || std::is_same_v, RightConverter>) + throw Exception(fmt::format("Any argument of function {} must not be Point", getName()), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + else { - boost::geometry::correct(first[i]); - boost::geometry::correct(second[i]); + auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); + auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - res_data.emplace_back(boost::geometry::distance(first[i], second[i])); + for (size_t i = 0; i < input_rows_count; i++) + { + boost::geometry::correct(first[i]); + boost::geometry::correct(second[i]); + + res_data.emplace_back(boost::geometry::distance(first[i], second[i])); + } } }); diff --git a/src/Functions/polygonsEquals.cpp b/src/Functions/polygonsEquals.cpp index d235e88b465..7e4882d5cc2 100644 --- a/src/Functions/polygonsEquals.cpp +++ b/src/Functions/polygonsEquals.cpp @@ -21,6 +21,10 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} template class FunctionPolygonsEquals : public IFunction @@ -69,16 +73,21 @@ public: using LeftConverter = typename LeftConverterType::Type; using RightConverter = typename RightConverterType::Type; - auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); - auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - - for (size_t i = 0; i < input_rows_count; i++) + if constexpr (std::is_same_v, LeftConverter> || std::is_same_v, RightConverter>) + throw Exception(fmt::format("Any argument of function {} must not be Point", getName()), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + else { - boost::geometry::correct(first[i]); - boost::geometry::correct(second[i]); + auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); + auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - /// Main work here. - res_data.emplace_back(boost::geometry::equals(first[i], second[i])); + for (size_t i = 0; i < input_rows_count; i++) + { + boost::geometry::correct(first[i]); + boost::geometry::correct(second[i]); + + /// Main work here. + res_data.emplace_back(boost::geometry::equals(first[i], second[i])); + } } } ); diff --git a/src/Functions/polygonsIntersection.cpp b/src/Functions/polygonsIntersection.cpp index 285255df031..331215e73e1 100644 --- a/src/Functions/polygonsIntersection.cpp +++ b/src/Functions/polygonsIntersection.cpp @@ -21,6 +21,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + template class FunctionPolygonsIntersection : public IFunction { @@ -67,22 +72,27 @@ public: using LeftConverter = typename LeftConverterType::Type; using RightConverter = typename RightConverterType::Type; - auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); - auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - - /// We are not interested in some pitfalls in third-party libraries - /// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) - for (size_t i = 0; i < input_rows_count; ++i) + if constexpr (std::is_same_v, LeftConverter> || std::is_same_v, RightConverter>) + throw Exception(fmt::format("Any argument of function {} must not be Point", getName()), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + else { - /// Orient the polygons correctly. - boost::geometry::correct(first[i]); - boost::geometry::correct(second[i]); + auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); + auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - MultiPolygon intersection{}; - /// Main work here. - boost::geometry::intersection(first[i], second[i], intersection); + /// We are not interested in some pitfalls in third-party libraries + /// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) + for (size_t i = 0; i < input_rows_count; ++i) + { + /// Orient the polygons correctly. + boost::geometry::correct(first[i]); + boost::geometry::correct(second[i]); - serializer.add(intersection); + MultiPolygon intersection{}; + /// Main work here. + boost::geometry::intersection(first[i], second[i], intersection); + + serializer.add(intersection); + } } }); diff --git a/src/Functions/polygonsSymDifference.cpp b/src/Functions/polygonsSymDifference.cpp index 20b521f7d6b..b1207582e8b 100644 --- a/src/Functions/polygonsSymDifference.cpp +++ b/src/Functions/polygonsSymDifference.cpp @@ -20,6 +20,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + + template class FunctionPolygonsSymDifference : public IFunction { @@ -65,19 +71,24 @@ public: using LeftConverter = typename LeftConverterType::Type; using RightConverter = typename RightConverterType::Type; - auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); - auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - - /// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) - for (size_t i = 0; i < input_rows_count; i++) + if constexpr (std::is_same_v, LeftConverter> || std::is_same_v, RightConverter>) + throw Exception(fmt::format("Any argument of function {} must not be Point", getName()), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + else { - boost::geometry::correct(first[i]); - boost::geometry::correct(second[i]); + auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); + auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - MultiPolygon sym_difference{}; - boost::geometry::sym_difference(first[i], second[i], sym_difference); + /// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) + for (size_t i = 0; i < input_rows_count; i++) + { + boost::geometry::correct(first[i]); + boost::geometry::correct(second[i]); - serializer.add(sym_difference); + MultiPolygon sym_difference{}; + boost::geometry::sym_difference(first[i], second[i], sym_difference); + + serializer.add(sym_difference); + } } }); diff --git a/src/Functions/polygonsUnion.cpp b/src/Functions/polygonsUnion.cpp index f236bf13bc3..bd761c847b0 100644 --- a/src/Functions/polygonsUnion.cpp +++ b/src/Functions/polygonsUnion.cpp @@ -20,6 +20,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + + template class FunctionPolygonsUnion : public IFunction { @@ -65,22 +71,27 @@ public: using LeftConverter = typename LeftConverterType::Type; using RightConverter = typename RightConverterType::Type; - auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); - auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - - /// We are not interested in some pitfalls in third-party libraries - /// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) - for (size_t i = 0; i < input_rows_count; i++) + if constexpr (std::is_same_v, LeftConverter> || std::is_same_v, RightConverter>) + throw Exception(fmt::format("Any argument of function {} must not be Point", getName()), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + else { - /// Orient the polygons correctly. - boost::geometry::correct(first[i]); - boost::geometry::correct(second[i]); + auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); + auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - MultiPolygon polygons_union{}; - /// Main work here. - boost::geometry::union_(first[i], second[i], polygons_union); + /// We are not interested in some pitfalls in third-party libraries + /// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) + for (size_t i = 0; i < input_rows_count; i++) + { + /// Orient the polygons correctly. + boost::geometry::correct(first[i]); + boost::geometry::correct(second[i]); - serializer.add(polygons_union); + MultiPolygon polygons_union{}; + /// Main work here. + boost::geometry::union_(first[i], second[i], polygons_union); + + serializer.add(polygons_union); + } } }); diff --git a/src/Functions/polygonsWithin.cpp b/src/Functions/polygonsWithin.cpp index 1e591cf0de2..708ddeee547 100644 --- a/src/Functions/polygonsWithin.cpp +++ b/src/Functions/polygonsWithin.cpp @@ -22,6 +22,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + + template class FunctionPolygonsWithin : public IFunction { @@ -69,16 +75,21 @@ public: using LeftConverter = typename LeftConverterType::Type; using RightConverter = typename RightConverterType::Type; - auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); - auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - - /// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) - for (size_t i = 0; i < input_rows_count; i++) + if constexpr (std::is_same_v, LeftConverter> || std::is_same_v, RightConverter>) + throw Exception(fmt::format("Any argument of function {} must not be Point", getName()), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + else { - boost::geometry::correct(first[i]); - boost::geometry::correct(second[i]); + auto first = LeftConverter(arguments[0].column->convertToFullColumnIfConst()).convert(); + auto second = RightConverter(arguments[1].column->convertToFullColumnIfConst()).convert(); - res_data.emplace_back(boost::geometry::within(first[i], second[i])); + /// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign) + for (size_t i = 0; i < input_rows_count; i++) + { + boost::geometry::correct(first[i]); + boost::geometry::correct(second[i]); + + res_data.emplace_back(boost::geometry::within(first[i], second[i])); + } } }); diff --git a/src/Functions/svg.cpp b/src/Functions/svg.cpp index 2ad9f96ca15..873a42722c3 100644 --- a/src/Functions/svg.cpp +++ b/src/Functions/svg.cpp @@ -71,6 +71,7 @@ public: { using TypeConverter = std::decay_t; using Converter = typename TypeConverter::Type; + Converter converter(arguments[0].column->convertToFullColumnIfConst()); auto figures = converter.convert(); diff --git a/src/Functions/wkt.cpp b/src/Functions/wkt.cpp index 08aeb76dcdd..619c3f3aee8 100644 --- a/src/Functions/wkt.cpp +++ b/src/Functions/wkt.cpp @@ -44,6 +44,7 @@ public: { using TypeConverter = std::decay_t; using Converter = typename TypeConverter::Type; + Converter converter(arguments[0].column->convertToFullColumnIfConst()); auto figures = converter.convert(); diff --git a/tests/queries/0_stateless/01300_svg.reference b/tests/queries/0_stateless/01300_svg.reference index 925d3eed011..d39d67ff273 100644 --- a/tests/queries/0_stateless/01300_svg.reference +++ b/tests/queries/0_stateless/01300_svg.reference @@ -1,11 +1,11 @@ - - - + + + - - - + + + @@ -18,39 +18,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/queries/0_stateless/01300_svg.sql b/tests/queries/0_stateless/01300_svg.sql index d82572eeeba..3e70182023b 100644 --- a/tests/queries/0_stateless/01300_svg.sql +++ b/tests/queries/0_stateless/01300_svg.sql @@ -1,48 +1,48 @@ -SELECT svg((0, 0)); -SELECT svg([(0, 0), (10, 0), (10, 10), (0, 10)]); -SELECT svg([[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]]); -SELECT svg([[[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], [[(-10, -10), (-10, -9), (-9, 10)]]]); -SELECT svg((0, 0), 'b'); -SELECT svg([(0, 0), (10, 0), (10, 10), (0, 10)], 'b'); -SELECT svg([[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], 'b'); -SELECT svg([[[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], [[(-10, -10), (-10, -9), (-9, 10)]]], 'b'); +SELECT svg((0., 0.)); +SELECT svg([(0., 0.), (10, 0), (10, 10), (0, 10)]); +SELECT svg([[(0., 0.), (10, 0), (10, 10), (0, 10)], [(4., 4.), (5, 4), (5, 5), (4, 5)]]); +SELECT svg([[[(0., 0.), (10, 0), (10, 10), (0, 10)], [(4., 4.), (5, 4), (5, 5), (4, 5)]], [[(-10., -10.), (-10, -9), (-9, 10)]]]); +SELECT svg((0., 0.), 'b'); +SELECT svg([(0., 0.), (10, 0), (10, 10), (0, 10)], 'b'); +SELECT svg([[(0., 0.), (10, 0), (10, 10), (0, 10)], [(4., 4.), (5, 4), (5, 5), (4, 5)]], 'b'); +SELECT svg([[[(0., 0.), (10, 0), (10, 10), (0, 10)], [(4., 4.), (5, 4), (5, 5), (4, 5)]], [[(-10., -10.), (-10, -9), (-9, 10)]]], 'b'); DROP TABLE IF EXISTS geo; CREATE TABLE geo (p Tuple(Float64, Float64), s String, id Int) engine=Memory(); -INSERT INTO geo VALUES ((0, 0), 'b', 1); -INSERT INTO geo VALUES ((1, 0), 'c', 2); -INSERT INTO geo VALUES ((2, 0), 'd', 3); +INSERT INTO geo VALUES ((0., 0.), 'b', 1); +INSERT INTO geo VALUES ((1., 0.), 'c', 2); +INSERT INTO geo VALUES ((2., 0.), 'd', 3); SELECT svg(p) FROM geo ORDER BY id; SELECT svg(p, 'b') FROM geo ORDER BY id; -SELECT svg((0, 0), s) FROM geo ORDER BY id; +SELECT svg((0., 0.), s) FROM geo ORDER BY id; SELECT svg(p, s) FROM geo ORDER BY id; DROP TABLE IF EXISTS geo; CREATE TABLE geo (p Array(Tuple(Float64, Float64)), s String, id Int) engine=Memory(); -INSERT INTO geo VALUES ([(0, 0), (10, 0), (10, 10), (0, 10)], 'b', 1); -INSERT INTO geo VALUES ([(1, 0), (10, 0), (10, 10), (0, 10)], 'c', 2); -INSERT INTO geo VALUES ([(2, 0), (10, 0), (10, 10), (0, 10)], 'd', 3); +INSERT INTO geo VALUES ([(0., 0.), (10, 0), (10, 10), (0, 10)], 'b', 1); +INSERT INTO geo VALUES ([(1., 0.), (10, 0), (10, 10), (0, 10)], 'c', 2); +INSERT INTO geo VALUES ([(2., 0.), (10, 0), (10, 10), (0, 10)], 'd', 3); SELECT svg(p) FROM geo ORDER BY id; SELECT svg(p, 'b') FROM geo ORDER BY id; -SELECT svg([(0, 0), (10, 0), (10, 10), (0, 10)], s) FROM geo ORDER BY id; +SELECT svg([(0., 0.), (10, 0), (10, 10), (0, 10)], s) FROM geo ORDER BY id; SELECT svg(p, s) FROM geo ORDER BY id; DROP TABLE IF EXISTS geo; CREATE TABLE geo (p Array(Array(Tuple(Float64, Float64))), s String, id Int) engine=Memory(); -INSERT INTO geo VALUES ([[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], 'b', 1); -INSERT INTO geo VALUES ([[(1, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], 'c', 2); -INSERT INTO geo VALUES ([[(2, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], 'd', 3); +INSERT INTO geo VALUES ([[(0., 0.), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], 'b', 1); +INSERT INTO geo VALUES ([[(1., 0.), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], 'c', 2); +INSERT INTO geo VALUES ([[(2., 0.), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], 'd', 3); SELECT svg(p) FROM geo ORDER BY id; SELECT svg(p, 'b') FROM geo ORDER BY id; -SELECT svg([[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], s) FROM geo ORDER BY id; +SELECT svg([[(0., 0.), (10, 0), (10, 10), (0, 10)], [(4., 4.), (5, 4), (5, 5), (4, 5)]], s) FROM geo ORDER BY id; SELECT svg(p, s) FROM geo ORDER BY id; DROP TABLE IF EXISTS geo; CREATE TABLE geo (p Array(Array(Array(Tuple(Float64, Float64)))), s String, id Int) engine=Memory(); -INSERT INTO geo VALUES ([[[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], [[(-10, -10), (-10, -9), (-9, 10)]]], 'b', 1); -INSERT INTO geo VALUES ([[[(1, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], [[(-10, -10), (-10, -9), (-9, 10)]]], 'c', 2); -INSERT INTO geo VALUES ([[[(2, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], [[(-10, -10), (-10, -9), (-9, 10)]]], 'd', 3); +INSERT INTO geo VALUES ([[[(0., 0.), (10, 0), (10, 10), (0, 10)], [(4., 4.), (5, 4), (5, 5), (4, 5)]], [[(-10., -10.), (-10, -9), (-9, 10)]]], 'b', 1); +INSERT INTO geo VALUES ([[[(1., 0.), (10, 0), (10, 10), (0, 10)], [(4., 4.), (5, 4), (5, 5), (4, 5)]], [[(-10., -10.), (-10, -9), (-9, 10)]]], 'c', 2); +INSERT INTO geo VALUES ([[[(2., 0.), (10, 0), (10, 10), (0, 10)], [(4., 4.), (5, 4), (5, 5), (4, 5)]], [[(-10., -10.), (-10, -9), (-9, 10)]]], 'd', 3); SELECT svg(p) FROM geo ORDER BY id; SELECT svg(p, 'b') FROM geo ORDER BY id; -SELECT svg([[[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], [[(-10, -10), (-10, -9), (-9, 10)]]], s) FROM geo ORDER BY id; +SELECT svg([[[(0., 0.), (10, 0), (10, 10), (0, 10)], [(4., 4.), (5, 4), (5, 5), (4, 5)]], [[(-10., -10.), (-10, -9), (-9, 10)]]], s) FROM geo ORDER BY id; SELECT svg(p, s) FROM geo ORDER BY id; diff --git a/tests/queries/0_stateless/01300_wkt.reference b/tests/queries/0_stateless/01300_wkt.reference index c3ad0f4be67..0079e9f32df 100644 --- a/tests/queries/0_stateless/01300_wkt.reference +++ b/tests/queries/0_stateless/01300_wkt.reference @@ -1,13 +1,13 @@ POINT(0 0) -POLYGON((0 0,10 0,10 10,0 10,0 0)) +POLYGON((0 0,10 0,10 10,0 10)) POLYGON((0 0,10 0,10 10,0 10,0 0),(4 4,5 4,5 5,4 5,4 4)) MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(4 4,5 4,5 5,4 5,4 4)),((-10 -10,-10 -9,-9 10,-10 -10))) POINT(0 0) POINT(1 0) POINT(2 0) -POLYGON((0 0,10 0,10 10,0 10,0 0)) -POLYGON((1 0,10 0,10 10,0 10,1 0)) -POLYGON((2 0,10 0,10 10,0 10,2 0)) +POLYGON((0 0,10 0,10 10,0 10)) +POLYGON((1 0,10 0,10 10,0 10)) +POLYGON((2 0,10 0,10 10,0 10)) POLYGON((0 0,10 0,10 10,0 10,0 0),(4 4,5 4,5 5,4 5,4 4)) POLYGON((1 0,10 0,10 10,0 10,1 0),(4 4,5 4,5 5,4 5,4 4)) POLYGON((2 0,10 0,10 10,0 10,2 0),(4 4,5 4,5 5,4 5,4 4)) diff --git a/tests/queries/0_stateless/01300_wkt.sql b/tests/queries/0_stateless/01300_wkt.sql index a79d1a0c150..7047bb698bb 100644 --- a/tests/queries/0_stateless/01300_wkt.sql +++ b/tests/queries/0_stateless/01300_wkt.sql @@ -1,7 +1,7 @@ -SELECT wkt((0, 0)); -SELECT wkt([(0, 0), (10, 0), (10, 10), (0, 10)]); -SELECT wkt([[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]]); -SELECT wkt([[[(0, 0), (10, 0), (10, 10), (0, 10)], [(4, 4), (5, 4), (5, 5), (4, 5)]], [[(-10, -10), (-10, -9), (-9, 10)]]]); +SELECT wkt((0., 0.)); +SELECT wkt([(0., 0.), (10., 0.), (10., 10.), (0., 10.)]); +SELECT wkt([[(0., 0.), (10., 0.), (10., 10.), (0., 10.)], [(4., 4.), (5., 4.), (5., 5.), (4., 5.)]]); +SELECT wkt([[[(0., 0.), (10., 0.), (10., 10.), (0., 10.)], [(4., 4.), (5., 4.), (5., 5.), (4., 5.)]], [[(-10., -10.), (-10., -9.), (-9., 10.)]]]); DROP TABLE IF EXISTS geo; CREATE TABLE geo (p Tuple(Float64, Float64), id Int) engine=Memory();