From 23c9902433ffab5bcafd6b9edcbbaca8a6a4d6d7 Mon Sep 17 00:00:00 2001 From: Nico Mandery Date: Fri, 24 Jan 2020 21:16:06 +0100 Subject: [PATCH] h3 hierarchical functions and string conversion --- dbms/src/Functions/h3GetBaseCell.cpp | 66 +++++++++++++ dbms/src/Functions/h3HexAreaM2.cpp | 66 +++++++++++++ dbms/src/Functions/h3IndexesAreNeighbors.cpp | 74 ++++++++++++++ dbms/src/Functions/h3ToChildren.cpp | 91 +++++++++++++++++ dbms/src/Functions/h3ToParent.cpp | 74 ++++++++++++++ dbms/src/Functions/h3ToString.cpp | 82 ++++++++++++++++ dbms/src/Functions/registerFunctionsGeo.cpp | 14 +++ dbms/src/Functions/stringToH3.cpp | 97 +++++++++++++++++++ .../01070_h3_get_base_cell.reference | 1 + .../0_stateless/01070_h3_get_base_cell.sql | 1 + .../01070_h3_hex_area_m2.reference | 2 + .../0_stateless/01070_h3_hex_area_m2.sql | 2 + .../01070_h3_indexes_are_neighbors.reference | 3 + .../01070_h3_indexes_are_neighbors.sql | 3 + .../01070_h3_to_children.reference | 3 + .../0_stateless/01070_h3_to_children.sql | 5 + .../0_stateless/01070_h3_to_parent.reference | 2 + .../0_stateless/01070_h3_to_parent.sql | 2 + .../0_stateless/01070_h3_to_string.reference | 1 + .../0_stateless/01070_h3_to_string.sql | 1 + .../0_stateless/01070_string_to_h3.reference | 1 + .../0_stateless/01070_string_to_h3.sql | 1 + 22 files changed, 592 insertions(+) create mode 100644 dbms/src/Functions/h3GetBaseCell.cpp create mode 100644 dbms/src/Functions/h3HexAreaM2.cpp create mode 100644 dbms/src/Functions/h3IndexesAreNeighbors.cpp create mode 100644 dbms/src/Functions/h3ToChildren.cpp create mode 100644 dbms/src/Functions/h3ToParent.cpp create mode 100644 dbms/src/Functions/h3ToString.cpp create mode 100644 dbms/src/Functions/stringToH3.cpp create mode 100644 dbms/tests/queries/0_stateless/01070_h3_get_base_cell.reference create mode 100644 dbms/tests/queries/0_stateless/01070_h3_get_base_cell.sql create mode 100644 dbms/tests/queries/0_stateless/01070_h3_hex_area_m2.reference create mode 100644 dbms/tests/queries/0_stateless/01070_h3_hex_area_m2.sql create mode 100644 dbms/tests/queries/0_stateless/01070_h3_indexes_are_neighbors.reference create mode 100644 dbms/tests/queries/0_stateless/01070_h3_indexes_are_neighbors.sql create mode 100644 dbms/tests/queries/0_stateless/01070_h3_to_children.reference create mode 100644 dbms/tests/queries/0_stateless/01070_h3_to_children.sql create mode 100644 dbms/tests/queries/0_stateless/01070_h3_to_parent.reference create mode 100644 dbms/tests/queries/0_stateless/01070_h3_to_parent.sql create mode 100644 dbms/tests/queries/0_stateless/01070_h3_to_string.reference create mode 100644 dbms/tests/queries/0_stateless/01070_h3_to_string.sql create mode 100644 dbms/tests/queries/0_stateless/01070_string_to_h3.reference create mode 100644 dbms/tests/queries/0_stateless/01070_string_to_h3.sql diff --git a/dbms/src/Functions/h3GetBaseCell.cpp b/dbms/src/Functions/h3GetBaseCell.cpp new file mode 100644 index 00000000000..e36449270f7 --- /dev/null +++ b/dbms/src/Functions/h3GetBaseCell.cpp @@ -0,0 +1,66 @@ +#include "config_functions.h" +#if USE_H3 +# include +# include +# include +# include +# include +# include + +# include + + +namespace DB +{ +class FunctionH3GetBaseCell : public IFunction +{ +public: + static constexpr auto name = "h3GetBaseCell"; + + static FunctionPtr create(const Context &) { return std::make_shared(); } + + std::string getName() const override { return name; } + + size_t getNumberOfArguments() const override { return 1; } + bool useDefaultImplementationForConstants() const override { return true; } + + DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override + { + 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); + + return std::make_shared(); + } + + void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override + { + const auto col_hindex = block.getByPosition(arguments[0]).column.get(); + + auto dst = ColumnVector::create(); + auto & dst_data = dst->getData(); + dst_data.resize(input_rows_count); + + for (const auto row : ext::range(0, input_rows_count)) + { + const UInt64 hindex = col_hindex->getUInt(row); + + UInt8 res = h3GetBaseCell(hindex); + + dst_data[row] = res; + } + + block.getByPosition(result).column = std::move(dst); + } +}; + + +void registerFunctionH3GetBaseCell(FunctionFactory & factory) +{ + factory.registerFunction(); +} + +} +#endif diff --git a/dbms/src/Functions/h3HexAreaM2.cpp b/dbms/src/Functions/h3HexAreaM2.cpp new file mode 100644 index 00000000000..059293828db --- /dev/null +++ b/dbms/src/Functions/h3HexAreaM2.cpp @@ -0,0 +1,66 @@ +#include "config_functions.h" +#if USE_H3 +# include +# include +# include +# include +# include +# include + +# include + + +namespace DB +{ +class FunctionH3HexAreaM2 : public IFunction +{ +public: + static constexpr auto name = "h3HexAreaM2"; + + static FunctionPtr create(const Context &) { return std::make_shared(); } + + std::string getName() const override { return name; } + + size_t getNumberOfArguments() const override { return 1; } + bool useDefaultImplementationForConstants() const override { return true; } + + DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override + { + auto arg = arguments[0].get(); + if (!WhichDataType(arg).isUInt8()) + throw Exception( + "Illegal type " + arg->getName() + " of argument " + std::to_string(1) + " of function " + getName() + ". Must be UInt8", + ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + + return std::make_shared(); + } + + void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override + { + const auto col_hindex = block.getByPosition(arguments[0]).column.get(); + + auto dst = ColumnVector::create(); + auto & dst_data = dst->getData(); + dst_data.resize(input_rows_count); + + for (const auto row : ext::range(0, input_rows_count)) + { + const int resolution = col_hindex->getUInt(row); + + Float64 res = hexAreaM2(resolution); + + dst_data[row] = res; + } + + block.getByPosition(result).column = std::move(dst); + } +}; + + +void registerFunctionH3HexAreaM2(FunctionFactory & factory) +{ + factory.registerFunction(); +} + +} +#endif diff --git a/dbms/src/Functions/h3IndexesAreNeighbors.cpp b/dbms/src/Functions/h3IndexesAreNeighbors.cpp new file mode 100644 index 00000000000..e625e66a3b8 --- /dev/null +++ b/dbms/src/Functions/h3IndexesAreNeighbors.cpp @@ -0,0 +1,74 @@ +#include "config_functions.h" +#if USE_H3 +# include +# include +# include +# include +# include +# include + +# include + + +namespace DB +{ +class FunctionH3IndexesAreNeighbors : public IFunction +{ +public: + static constexpr auto name = "h3IndexesAreNeighbors"; + + static FunctionPtr create(const Context &) { return std::make_shared(); } + + std::string getName() const override { return name; } + + size_t getNumberOfArguments() const override { return 2; } + bool useDefaultImplementationForConstants() const override { return true; } + + DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override + { + 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); + + 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); + + return std::make_shared(); + } + + void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override + { + const auto col_hindex_origin = block.getByPosition(arguments[0]).column.get(); + const auto col_hindex_dest = block.getByPosition(arguments[1]).column.get(); + + auto dst = ColumnVector::create(); + auto & dst_data = dst->getData(); + dst_data.resize(input_rows_count); + + for (const auto row : ext::range(0, input_rows_count)) + { + const UInt64 hindex_origin = col_hindex_origin->getUInt(row); + const UInt64 hindex_dest = col_hindex_dest->getUInt(row); + + UInt8 res = h3IndexesAreNeighbors(hindex_origin, hindex_dest); + + dst_data[row] = res; + } + + block.getByPosition(result).column = std::move(dst); + } +}; + + +void registerFunctionH3IndexesAreNeighbors(FunctionFactory & factory) +{ + factory.registerFunction(); +} + +} +#endif diff --git a/dbms/src/Functions/h3ToChildren.cpp b/dbms/src/Functions/h3ToChildren.cpp new file mode 100644 index 00000000000..03bf4ffb7b5 --- /dev/null +++ b/dbms/src/Functions/h3ToChildren.cpp @@ -0,0 +1,91 @@ +#include "config_functions.h" +#if USE_H3 +# include +# include +# include +# include +# include +# include +# include +# include + +# include + + +namespace DB +{ +class FunctionH3ToChildren : public IFunction +{ +public: + static constexpr auto name = "h3ToChildren"; + + static FunctionPtr create(const Context &) { return std::make_shared(); } + + std::string getName() const override { return name; } + + size_t getNumberOfArguments() const override { return 2; } + bool useDefaultImplementationForConstants() const override { return true; } + + DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override + { + 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); + + arg = arguments[1].get(); + if (!WhichDataType(arg).isUInt8()) + throw Exception( + "Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " of function " + getName() + ". Must be UInt8", + ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + + return std::make_shared(std::make_shared()); + } + + void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override + { + const auto col_hindex = block.getByPosition(arguments[0]).column.get(); + const auto col_resolution = block.getByPosition(arguments[1]).column.get(); + + auto dst = ColumnArray::create(ColumnUInt64::create()); + auto & dst_data = dst->getData(); + auto & dst_offsets = dst->getOffsets(); + dst_offsets.resize(input_rows_count); + auto current_offset = 0; + + std::vector hindex_vec; + + for (const auto row : ext::range(0, input_rows_count)) + { + const UInt64 parent_hindex = col_hindex->getUInt(row); + const UInt8 child_resolution = col_resolution->getUInt(row); + + const auto vec_size = maxH3ToChildrenSize(parent_hindex, child_resolution); + hindex_vec.resize(vec_size); + h3ToChildren(parent_hindex, child_resolution, hindex_vec.data()); + + dst_data.reserve(dst_data.size() + vec_size); + for (auto hindex : hindex_vec) + { + if (hindex != 0) + { + ++current_offset; + dst_data.insert(hindex); + } + } + dst_offsets[row] = current_offset; + } + + block.getByPosition(result).column = std::move(dst); + } +}; + + +void registerFunctionH3ToChildren(FunctionFactory & factory) +{ + factory.registerFunction(); +} + +} +#endif diff --git a/dbms/src/Functions/h3ToParent.cpp b/dbms/src/Functions/h3ToParent.cpp new file mode 100644 index 00000000000..dd57d57c18d --- /dev/null +++ b/dbms/src/Functions/h3ToParent.cpp @@ -0,0 +1,74 @@ +#include "config_functions.h" +#if USE_H3 +# include +# include +# include +# include +# include +# include + +# include + + +namespace DB +{ +class FunctionH3ToParent : public IFunction +{ +public: + static constexpr auto name = "h3ToParent"; + + static FunctionPtr create(const Context &) { return std::make_shared(); } + + std::string getName() const override { return name; } + + size_t getNumberOfArguments() const override { return 2; } + bool useDefaultImplementationForConstants() const override { return true; } + + DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override + { + 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); + + arg = arguments[1].get(); + if (!WhichDataType(arg).isUInt8()) + throw Exception( + "Illegal type " + arg->getName() + " of argument " + std::to_string(2) + " of function " + getName() + ". Must be UInt8", + ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + + return std::make_shared(); + } + + void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override + { + const auto col_hindex = block.getByPosition(arguments[0]).column.get(); + const auto col_resolution = block.getByPosition(arguments[1]).column.get(); + + auto dst = ColumnVector::create(); + auto & dst_data = dst->getData(); + dst_data.resize(input_rows_count); + + for (const auto row : ext::range(0, input_rows_count)) + { + const UInt64 hindex = col_hindex->getUInt(row); + const UInt8 resolution = col_resolution->getUInt(row); + + UInt64 res = h3ToParent(hindex, resolution); + + dst_data[row] = res; + } + + block.getByPosition(result).column = std::move(dst); + } +}; + + +void registerFunctionH3ToParent(FunctionFactory & factory) +{ + factory.registerFunction(); +} + +} +#endif diff --git a/dbms/src/Functions/h3ToString.cpp b/dbms/src/Functions/h3ToString.cpp new file mode 100644 index 00000000000..a651f3005e5 --- /dev/null +++ b/dbms/src/Functions/h3ToString.cpp @@ -0,0 +1,82 @@ +#include "config_functions.h" +#if USE_H3 +# include +# include +# include +# include +# include + +# include + +# define H3_INDEX_STRING_LENGTH 17 // includes \0 terminator + +namespace DB +{ +class FunctionH3ToString : public IFunction +{ +public: + static constexpr auto name = "h3ToString"; + + static FunctionPtr create(const Context &) { return std::make_shared(); } + + std::string getName() const override { return name; } + + size_t getNumberOfArguments() const override { return 1; } + + bool useDefaultImplementationForConstants() const override { return true; } + + DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override + { + 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); + + return std::make_shared(); + } + + void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override + { + const auto col_hindex = block.getByPosition(arguments[0]).column.get(); + + auto col_res = ColumnString::create(); + auto & vec_res = col_res->getChars(); + auto & vec_offsets = col_res->getOffsets(); + + vec_offsets.resize(input_rows_count); + vec_res.resize_fill(input_rows_count * H3_INDEX_STRING_LENGTH, '\0'); + + char * begin = reinterpret_cast(vec_res.data()); + char * pos = begin; + + for (size_t i = 0; i < input_rows_count; ++i) + { + const UInt64 hindex = col_hindex->getUInt(i); + + if (!h3IsValid(hindex)) + { + throw Exception("Invalid H3 index: " + std::to_string(hindex), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + } + h3ToString(hindex, pos, H3_INDEX_STRING_LENGTH); + + // move to end of the index + while (*pos != '\0') + { + pos++; + } + vec_offsets[i] = ++pos - begin; + } + vec_res.resize(pos - begin); + block.getByPosition(result).column = std::move(col_res); + } +}; + + +void registerFunctionH3ToString(FunctionFactory & factory) +{ + factory.registerFunction(); +} + +} +#endif diff --git a/dbms/src/Functions/registerFunctionsGeo.cpp b/dbms/src/Functions/registerFunctionsGeo.cpp index d7c54986f8d..cb3c268a19a 100644 --- a/dbms/src/Functions/registerFunctionsGeo.cpp +++ b/dbms/src/Functions/registerFunctionsGeo.cpp @@ -19,6 +19,13 @@ void registerFunctionH3EdgeLengthM(FunctionFactory &); void registerFunctionH3GetResolution(FunctionFactory &); void registerFunctionH3IsValid(FunctionFactory &); void registerFunctionH3KRing(FunctionFactory &); +void registerFunctionH3GetBaseCell(FunctionFactory &); +void registerFunctionH3ToParent(FunctionFactory &); +void registerFunctionH3ToChildren(FunctionFactory &); +void registerFunctionH3IndexesAreNeighbors(FunctionFactory &); +void registerFunctionStringToH3(FunctionFactory &); +void registerFunctionH3ToString(FunctionFactory &); +void registerFunctionH3HexAreaM2(FunctionFactory &); #endif @@ -38,6 +45,13 @@ void registerFunctionsGeo(FunctionFactory & factory) registerFunctionH3GetResolution(factory); registerFunctionH3IsValid(factory); registerFunctionH3KRing(factory); + registerFunctionH3GetBaseCell(factory); + registerFunctionH3ToParent(factory); + registerFunctionH3ToChildren(factory); + registerFunctionH3IndexesAreNeighbors(factory); + registerFunctionStringToH3(factory); + registerFunctionH3ToString(factory); + registerFunctionH3HexAreaM2(factory); #endif } diff --git a/dbms/src/Functions/stringToH3.cpp b/dbms/src/Functions/stringToH3.cpp new file mode 100644 index 00000000000..0d7a4dcd337 --- /dev/null +++ b/dbms/src/Functions/stringToH3.cpp @@ -0,0 +1,97 @@ +#include "config_functions.h" +#if USE_H3 +# include +# include +# include +# include +# include +# include +# include +# include + +# include + + +namespace DB +{ + +using namespace GatherUtils; + +class FunctionStringToH3 : public IFunction +{ +public: + static constexpr auto name = "stringToH3"; + + static FunctionPtr create(const Context &) { return std::make_shared(); } + + std::string getName() const override { return name; } + + size_t getNumberOfArguments() const override { return 1; } + bool useDefaultImplementationForConstants() const override { return true; } + + DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override + { + auto arg = arguments[0].get(); + if (!WhichDataType(arg).isStringOrFixedString()) + throw Exception( + "Illegal type " + arg->getName() + " of argument " + std::to_string(1) + " of function " + getName() + ". Must be String or FixedString", + ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + + return std::make_shared(); + } + + void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override + { + const auto col_hindex = block.getByPosition(arguments[0]).column.get(); + + auto dst = ColumnVector::create(); + auto & dst_data = dst->getData(); + dst_data.resize(input_rows_count); + + if (auto * h3index = checkAndGetColumn(col_hindex)) + execute(StringSource(*h3index), dst_data); + else if (auto * h3index_fixed = checkAndGetColumn(col_hindex)) + execute(FixedStringSource(*h3index_fixed), dst_data); + else if (const ColumnConst * h3index_const = checkAndGetColumnConst(col_hindex)) + execute>(ConstSource(*h3index_const), dst_data); + else if (const ColumnConst * h3index_const_fixed = checkAndGetColumnConst(col_hindex)) + execute>(ConstSource(*h3index_const_fixed), dst_data); + else + throw Exception("Illegal column as argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN); + + block.getByPosition(result).column = std::move(dst); + } + +private: + template + static void execute(H3IndexSource h3index_source, PaddedPODArray & res_data) + { + size_t row_num = 0; + + while (!h3index_source.isEnd()) + { + auto h3index = h3index_source.getWhole(); + + // covert to std::string and get the c_str to have the delimiting \0 at the end. + auto h3index_str = StringRef(h3index.data, h3index.size).toString(); + res_data[row_num] = stringToH3(h3index_str.c_str()); + + if (res_data[row_num] == 0) + { + throw Exception("Invalid H3 index: " + h3index_str, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + } + + h3index_source.next(); + ++row_num; + } + } +}; + + +void registerFunctionStringToH3(FunctionFactory & factory) +{ + factory.registerFunction(); +} + +} +#endif diff --git a/dbms/tests/queries/0_stateless/01070_h3_get_base_cell.reference b/dbms/tests/queries/0_stateless/01070_h3_get_base_cell.reference new file mode 100644 index 00000000000..48082f72f08 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_get_base_cell.reference @@ -0,0 +1 @@ +12 diff --git a/dbms/tests/queries/0_stateless/01070_h3_get_base_cell.sql b/dbms/tests/queries/0_stateless/01070_h3_get_base_cell.sql new file mode 100644 index 00000000000..b06a12daf4a --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_get_base_cell.sql @@ -0,0 +1 @@ +SELECT h3GetBaseCell(612916788725809151); diff --git a/dbms/tests/queries/0_stateless/01070_h3_hex_area_m2.reference b/dbms/tests/queries/0_stateless/01070_h3_hex_area_m2.reference new file mode 100644 index 00000000000..44daea6616b --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_hex_area_m2.reference @@ -0,0 +1,2 @@ +252903364.5 +43.9 diff --git a/dbms/tests/queries/0_stateless/01070_h3_hex_area_m2.sql b/dbms/tests/queries/0_stateless/01070_h3_hex_area_m2.sql new file mode 100644 index 00000000000..b282485da77 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_hex_area_m2.sql @@ -0,0 +1,2 @@ +SELECT h3HexAreaM2(5); +SELECT h3HexAreaM2(13); diff --git a/dbms/tests/queries/0_stateless/01070_h3_indexes_are_neighbors.reference b/dbms/tests/queries/0_stateless/01070_h3_indexes_are_neighbors.reference new file mode 100644 index 00000000000..7938dcdde86 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_indexes_are_neighbors.reference @@ -0,0 +1,3 @@ +0 +1 +0 diff --git a/dbms/tests/queries/0_stateless/01070_h3_indexes_are_neighbors.sql b/dbms/tests/queries/0_stateless/01070_h3_indexes_are_neighbors.sql new file mode 100644 index 00000000000..52449654b29 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_indexes_are_neighbors.sql @@ -0,0 +1,3 @@ +SELECT h3IndexesAreNeighbors(617420388352917503, 617420388352655359); +SELECT h3IndexesAreNeighbors(617420388351344639, 617420388352655359); +SELECT h3IndexesAreNeighbors(617420388351344639, 617420388351344639); diff --git a/dbms/tests/queries/0_stateless/01070_h3_to_children.reference b/dbms/tests/queries/0_stateless/01070_h3_to_children.reference new file mode 100644 index 00000000000..bb32b687084 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_to_children.reference @@ -0,0 +1,3 @@ +[] +[603909588852408319,603909588986626047,603909589120843775,603909589255061503,603909589389279231,603909589523496959,603909589657714687] +[612916787975028735,612916787977125887,612916787979223039,612916787981320191,612916787983417343,612916787985514495,612916787987611647,612916787991805951,612916787993903103,612916787996000255,612916787998097407,612916788000194559,612916788002291711,612916788004388863,612916788008583167,612916788010680319,612916788012777471,612916788014874623,612916788016971775,612916788019068927,612916788021166079,612916788025360383,612916788027457535,612916788029554687,612916788031651839,612916788033748991,612916788035846143,612916788037943295,612916788042137599,612916788044234751,612916788046331903,612916788048429055,612916788050526207,612916788052623359,612916788054720511,612916788058914815,612916788061011967,612916788063109119,612916788065206271,612916788067303423,612916788069400575,612916788071497727,612916788075692031,612916788077789183,612916788079886335,612916788081983487,612916788084080639,612916788086177791,612916788088274943,612916788109246463,612916788111343615,612916788113440767,612916788115537919,612916788117635071,612916788119732223,612916788121829375,612916788126023679,612916788128120831,612916788130217983,612916788132315135,612916788134412287,612916788136509439,612916788138606591,612916788142800895,612916788144898047,612916788146995199,612916788149092351,612916788151189503,612916788153286655,612916788155383807,612916788159578111,612916788161675263,612916788163772415,612916788165869567,612916788167966719,612916788170063871,612916788172161023,612916788176355327,612916788178452479,612916788180549631,612916788182646783,612916788184743935,612916788186841087,612916788188938239,612916788193132543,612916788195229695,612916788197326847,612916788199423999,612916788201521151,612916788203618303,612916788205715455,612916788209909759,612916788212006911,612916788214104063,612916788216201215,612916788218298367,612916788220395519,612916788222492671,612916788243464191,612916788245561343,612916788247658495,612916788249755647,612916788251852799,612916788253949951,612916788256047103,612916788260241407,612916788262338559,612916788264435711,612916788266532863,612916788268630015,612916788270727167,612916788272824319,612916788277018623,612916788279115775,612916788281212927,612916788283310079,612916788285407231,612916788287504383,612916788289601535,612916788293795839,612916788295892991,612916788297990143,612916788300087295,612916788302184447,612916788304281599,612916788306378751,612916788310573055,612916788312670207,612916788314767359,612916788316864511,612916788318961663,612916788321058815,612916788323155967,612916788327350271,612916788329447423,612916788331544575,612916788333641727,612916788335738879,612916788337836031,612916788339933183,612916788344127487,612916788346224639,612916788348321791,612916788350418943,612916788352516095,612916788354613247,612916788356710399,612916788377681919,612916788379779071,612916788381876223,612916788383973375,612916788386070527,612916788388167679,612916788390264831,612916788394459135,612916788396556287,612916788398653439,612916788400750591,612916788402847743,612916788404944895,612916788407042047,612916788411236351,612916788413333503,612916788415430655,612916788417527807,612916788419624959,612916788421722111,612916788423819263,612916788428013567,612916788430110719,612916788432207871,612916788434305023,612916788436402175,612916788438499327,612916788440596479,612916788444790783,612916788446887935,612916788448985087,612916788451082239,612916788453179391,612916788455276543,612916788457373695,612916788461567999,612916788463665151,612916788465762303,612916788467859455,612916788469956607,612916788472053759,612916788474150911,612916788478345215,612916788480442367,612916788482539519,612916788484636671,612916788486733823,612916788488830975,612916788490928127,612916788511899647,612916788513996799,612916788516093951,612916788518191103,612916788520288255,612916788522385407,612916788524482559,612916788528676863,612916788530774015,612916788532871167,612916788534968319,612916788537065471,612916788539162623,612916788541259775,612916788545454079,612916788547551231,612916788549648383,612916788551745535,612916788553842687,612916788555939839,612916788558036991,612916788562231295,612916788564328447,612916788566425599,612916788568522751,612916788570619903,612916788572717055,612916788574814207,612916788579008511,612916788581105663,612916788583202815,612916788585299967,612916788587397119,612916788589494271,612916788591591423,612916788595785727,612916788597882879,612916788599980031,612916788602077183,612916788604174335,612916788606271487,612916788608368639,612916788612562943,612916788614660095,612916788616757247,612916788618854399,612916788620951551,612916788623048703,612916788625145855,612916788646117375,612916788648214527,612916788650311679,612916788652408831,612916788654505983,612916788656603135,612916788658700287,612916788662894591,612916788664991743,612916788667088895,612916788669186047,612916788671283199,612916788673380351,612916788675477503,612916788679671807,612916788681768959,612916788683866111,612916788685963263,612916788688060415,612916788690157567,612916788692254719,612916788696449023,612916788698546175,612916788700643327,612916788702740479,612916788704837631,612916788706934783,612916788709031935,612916788713226239,612916788715323391,612916788717420543,612916788719517695,612916788721614847,612916788723711999,612916788725809151,612916788730003455,612916788732100607,612916788734197759,612916788736294911,612916788738392063,612916788740489215,612916788742586367,612916788746780671,612916788748877823,612916788750974975,612916788753072127,612916788755169279,612916788757266431,612916788759363583,612916788780335103,612916788782432255,612916788784529407,612916788786626559,612916788788723711,612916788790820863,612916788792918015,612916788797112319,612916788799209471,612916788801306623,612916788803403775,612916788805500927,612916788807598079,612916788809695231,612916788813889535,612916788815986687,612916788818083839,612916788820180991,612916788822278143,612916788824375295,612916788826472447,612916788830666751,612916788832763903,612916788834861055,612916788836958207,612916788839055359,612916788841152511,612916788843249663,612916788847443967,612916788849541119,612916788851638271,612916788853735423,612916788855832575,612916788857929727,612916788860026879,612916788864221183,612916788866318335,612916788868415487,612916788870512639,612916788872609791,612916788874706943,612916788876804095,612916788880998399,612916788883095551,612916788885192703,612916788887289855,612916788889387007,612916788891484159,612916788893581311] diff --git a/dbms/tests/queries/0_stateless/01070_h3_to_children.sql b/dbms/tests/queries/0_stateless/01070_h3_to_children.sql new file mode 100644 index 00000000000..647d4cef078 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_to_children.sql @@ -0,0 +1,5 @@ +SELECT arraySort(h3ToChildren(599405990164561919, 3)); + +SELECT arraySort(h3ToChildren(599405990164561919, 6)); + +SELECT arraySort(h3ToChildren(599405990164561919, 8)); diff --git a/dbms/tests/queries/0_stateless/01070_h3_to_parent.reference b/dbms/tests/queries/0_stateless/01070_h3_to_parent.reference new file mode 100644 index 00000000000..30be6741834 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_to_parent.reference @@ -0,0 +1,2 @@ +590398848891879423 +576918149140578303 diff --git a/dbms/tests/queries/0_stateless/01070_h3_to_parent.sql b/dbms/tests/queries/0_stateless/01070_h3_to_parent.sql new file mode 100644 index 00000000000..5052f4b7b92 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_to_parent.sql @@ -0,0 +1,2 @@ +SELECT h3ToParent(599405990164561919, 3); +SELECT h3ToParent(599405990164561919, 0); diff --git a/dbms/tests/queries/0_stateless/01070_h3_to_string.reference b/dbms/tests/queries/0_stateless/01070_h3_to_string.reference new file mode 100644 index 00000000000..980fd4a1362 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_to_string.reference @@ -0,0 +1 @@ +89184926cdbffff diff --git a/dbms/tests/queries/0_stateless/01070_h3_to_string.sql b/dbms/tests/queries/0_stateless/01070_h3_to_string.sql new file mode 100644 index 00000000000..358c5ae18d2 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_h3_to_string.sql @@ -0,0 +1 @@ +SELECT h3ToString(617420388352917503); diff --git a/dbms/tests/queries/0_stateless/01070_string_to_h3.reference b/dbms/tests/queries/0_stateless/01070_string_to_h3.reference new file mode 100644 index 00000000000..df443495e20 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_string_to_h3.reference @@ -0,0 +1 @@ +617420388351344639 diff --git a/dbms/tests/queries/0_stateless/01070_string_to_h3.sql b/dbms/tests/queries/0_stateless/01070_string_to_h3.sql new file mode 100644 index 00000000000..47b02d9f88b --- /dev/null +++ b/dbms/tests/queries/0_stateless/01070_string_to_h3.sql @@ -0,0 +1 @@ +SELECT stringToH3('89184926cc3ffff');