Skip to content

Commit 38f291c

Browse files
authoredMay 17, 2022
Merge pull request ClickHouse#37030 from bharatnc/ncb/h3-missing-traversal-funcs
add remaining h3 traversal funcs

14 files changed

+739
-0
lines changed
 

‎docs/en/sql-reference/functions/geo/h3.md

+115
Original file line numberDiff line numberDiff line change
@@ -1026,4 +1026,119 @@ Result:
10261026
│ 41162 │
10271027
└─────────────┘
10281028
```
1029+
1030+
## h3Line {#h3line}
1031+
1032+
Returns the line of indices between the two indices that are provided.
1033+
1034+
**Syntax**
1035+
1036+
``` sql
1037+
h3Line(start,end)
1038+
```
1039+
1040+
**Parameter**
1041+
1042+
- `start` — Hexagon index number that represents a starting point. Type: [UInt64](../../../sql-reference/data-types/int-uint.md).
1043+
- `end` — Hexagon index number that represents an ending point. Type: [UInt64](../../../sql-reference/data-types/int-uint.md).
1044+
1045+
**Returned value**
1046+
1047+
Array of h3 indexes representing the line of indices between the two provided indices:
1048+
1049+
Type: [Array](../../../sql-reference/data-types/array.md)([UInt64](../../../sql-reference/data-types/int-uint.md)).
1050+
1051+
**Example**
1052+
1053+
Query:
1054+
1055+
``` sql
1056+
SELECT h3Line(590080540275638271,590103561300344831) as indexes;
1057+
```
1058+
1059+
Result:
1060+
1061+
``` text
1062+
┌─indexes────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
1063+
│ [590080540275638271,590080471556161535,590080883873021951,590106516237844479,590104385934065663,590103630019821567,590103561300344831] │
1064+
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
1065+
```
1066+
1067+
## h3Distance {#h3distance}
1068+
1069+
Returns the distance in grid cells between the two indices that are provided.
1070+
1071+
**Syntax**
1072+
1073+
``` sql
1074+
h3Distance(start,end)
1075+
```
1076+
1077+
**Parameter**
1078+
1079+
- `start` — Hexagon index number that represents a starting point. Type: [UInt64](../../../sql-reference/data-types/int-uint.md).
1080+
- `end` — Hexagon index number that represents an ending point. Type: [UInt64](../../../sql-reference/data-types/int-uint.md).
1081+
1082+
**Returned value**
1083+
1084+
- Number of grid cells.
1085+
1086+
Type: [Int64](../../../sql-reference/data-types/int-uint.md).
1087+
1088+
Returns a negative number if finding the distance fails.
1089+
1090+
**Example**
1091+
1092+
Query:
1093+
1094+
``` sql
1095+
SELECT h3Distance(590080540275638271,590103561300344831) as distance;
1096+
```
1097+
1098+
Result:
1099+
1100+
``` text
1101+
┌─distance─┐
1102+
│ 7 │
1103+
└──────────┘
1104+
```
1105+
1106+
## h3HexRing {#h3hexring}
1107+
1108+
Returns the indexes of the hexagonal ring centered at the provided origin h3Index and length k.
1109+
1110+
Returns 0 if no pentagonal distortion was encountered.
1111+
1112+
**Syntax**
1113+
1114+
``` sql
1115+
h3HexRing(index, k)
1116+
```
1117+
1118+
**Parameter**
1119+
1120+
- `index` — Hexagon index number that represents the origin. Type: [UInt64](../../../sql-reference/data-types/int-uint.md).
1121+
- `k` — Distance. Type: [UInt64](../../../sql-reference/data-types/int-uint.md).
1122+
1123+
**Returned values**
1124+
1125+
- Array of H3 indexes.
1126+
1127+
Type: [Array](../../../sql-reference/data-types/array.md)([UInt64](../../../sql-reference/data-types/int-uint.md)).
1128+
1129+
**Example**
1130+
1131+
Query:
1132+
1133+
``` sql
1134+
SELECT h3HexRing(590080540275638271, toUInt16(1)) AS hexRing;
1135+
```
1136+
1137+
Result:
1138+
1139+
``` text
1140+
┌─hexRing─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
1141+
│ [590080815153545215,590080471556161535,590080677714591743,590077585338138623,590077447899185151,590079509483487231] │
1142+
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
1143+
```
10291144
[Original article](https://clickhouse.com/docs/en/sql-reference/functions/geo/h3) <!--hide-->

‎src/Functions/h3Distance.cpp

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#include "config_functions.h"
2+
3+
#if USE_H3
4+
5+
#include <Columns/ColumnArray.h>
6+
#include <Columns/ColumnsNumber.h>
7+
#include <DataTypes/DataTypeArray.h>
8+
#include <DataTypes/DataTypesNumber.h>
9+
#include <Functions/FunctionFactory.h>
10+
#include <Functions/IFunction.h>
11+
#include <Common/typeid_cast.h>
12+
#include <IO/WriteHelpers.h>
13+
#include <base/range.h>
14+
15+
#include <constants.h>
16+
#include <h3api.h>
17+
18+
19+
namespace DB
20+
{
21+
namespace ErrorCodes
22+
{
23+
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
24+
extern const int ILLEGAL_COLUMN;
25+
}
26+
27+
namespace
28+
{
29+
30+
class FunctionH3Distance : public IFunction
31+
{
32+
public:
33+
static constexpr auto name = "h3Distance";
34+
35+
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionH3Distance>(); }
36+
37+
std::string getName() const override { return name; }
38+
39+
size_t getNumberOfArguments() const override { return 2; }
40+
bool useDefaultImplementationForConstants() const override { return true; }
41+
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
42+
43+
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
44+
{
45+
const auto * arg = arguments[0].get();
46+
if (!WhichDataType(arg).isUInt64())
47+
throw Exception(
48+
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
49+
"Illegal type {} of argument {} of function {}. Must be UInt64",
50+
arg->getName(), 1, getName());
51+
52+
arg = arguments[1].get();
53+
if (!WhichDataType(arg).isUInt64())
54+
throw Exception(
55+
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
56+
"Illegal type {} of argument {} of function {}. Must be UInt64",
57+
arg->getName(), 2, getName());
58+
59+
return std::make_shared<DataTypeInt64>();
60+
}
61+
62+
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override
63+
{
64+
auto non_const_arguments = arguments;
65+
for (auto & argument : non_const_arguments)
66+
argument.column = argument.column->convertToFullColumnIfConst();
67+
68+
const auto * col_start_index = checkAndGetColumn<ColumnUInt64>(non_const_arguments[0].column.get());
69+
if (!col_start_index)
70+
throw Exception(
71+
ErrorCodes::ILLEGAL_COLUMN,
72+
"Illegal type {} of argument {} of function {}. Must be UInt64.",
73+
arguments[0].type->getName(),
74+
1,
75+
getName());
76+
77+
const auto & data_start_index = col_start_index->getData();
78+
79+
const auto * col_end_index = checkAndGetColumn<ColumnUInt64>(non_const_arguments[1].column.get());
80+
if (!col_end_index)
81+
throw Exception(
82+
ErrorCodes::ILLEGAL_COLUMN,
83+
"Illegal type {} of argument {} of function {}. Must be UInt64.",
84+
arguments[1].type->getName(),
85+
2,
86+
getName());
87+
88+
const auto & data_end_index = col_end_index->getData();
89+
90+
91+
auto dst = ColumnVector<Int64>::create();
92+
auto & dst_data = dst->getData();
93+
dst_data.resize(input_rows_count);
94+
95+
for (size_t row = 0; row < input_rows_count; ++row)
96+
{
97+
const UInt64 start = data_start_index[row];
98+
const UInt64 end = data_end_index[row];
99+
100+
auto size = gridPathCellsSize(start, end);
101+
dst_data[row] = size;
102+
}
103+
104+
return dst;
105+
}
106+
};
107+
108+
}
109+
110+
void registerFunctionH3Distance(FunctionFactory & factory)
111+
{
112+
factory.registerFunction<FunctionH3Distance>();
113+
}
114+
115+
}
116+
117+
#endif

‎src/Functions/h3HexRing.cpp

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#include "config_functions.h"
2+
3+
#if USE_H3
4+
5+
#include <vector>
6+
#include <Columns/ColumnArray.h>
7+
#include <Columns/ColumnsNumber.h>
8+
#include <DataTypes/DataTypeArray.h>
9+
#include <DataTypes/DataTypesNumber.h>
10+
#include <DataTypes/IDataType.h>
11+
#include <Functions/FunctionFactory.h>
12+
#include <Functions/IFunction.h>
13+
#include <Common/typeid_cast.h>
14+
15+
#include <h3api.h>
16+
17+
18+
namespace DB
19+
{
20+
21+
namespace ErrorCodes
22+
{
23+
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
24+
extern const int PARAMETER_OUT_OF_BOUND;
25+
extern const int ILLEGAL_COLUMN;
26+
extern const int INCORRECT_DATA;
27+
}
28+
29+
namespace
30+
{
31+
32+
class FunctionH3HexRing : public IFunction
33+
{
34+
public:
35+
static constexpr auto name = "h3HexRing";
36+
37+
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionH3HexRing>(); }
38+
39+
std::string getName() const override { return name; }
40+
41+
size_t getNumberOfArguments() const override { return 2; }
42+
bool useDefaultImplementationForConstants() const override { return true; }
43+
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
44+
45+
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
46+
{
47+
const auto * arg = arguments[0].get();
48+
if (!WhichDataType(arg).isUInt64())
49+
throw Exception(
50+
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
51+
"Illegal type {} of argument {} of function {}. Must be UInt64",
52+
arg->getName(), 1, getName());
53+
54+
arg = arguments[1].get();
55+
if (!WhichDataType(arg).isUInt16())
56+
throw Exception(
57+
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
58+
"Illegal type {} of argument {} of function {}. Must be UInt16",
59+
arg->getName(),
60+
2,
61+
getName());
62+
63+
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>());
64+
}
65+
66+
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override
67+
{
68+
auto non_const_arguments = arguments;
69+
for (auto & argument : non_const_arguments)
70+
argument.column = argument.column->convertToFullColumnIfConst();
71+
72+
const auto * col_hindex = checkAndGetColumn<ColumnUInt64>(non_const_arguments[0].column.get());
73+
if (!col_hindex)
74+
throw Exception(
75+
ErrorCodes::ILLEGAL_COLUMN,
76+
"Illegal type {} of argument {} of function {}. Must be UInt64.",
77+
arguments[0].type->getName(),
78+
1,
79+
getName());
80+
81+
const auto & data_hindex = col_hindex->getData();
82+
83+
/// ColumnUInt16 is sufficient as the max value of 2nd arg is checked (arg > 0 < 10000) in implementation below
84+
const auto * col_k = checkAndGetColumn<ColumnUInt16>(non_const_arguments[1].column.get());
85+
if (!col_k)
86+
throw Exception(
87+
ErrorCodes::ILLEGAL_COLUMN,
88+
"Illegal type {} of argument {} of function {}. Must be UInt16.",
89+
arguments[1].type->getName(),
90+
2,
91+
getName());
92+
93+
const auto & data_k = col_k->getData();
94+
95+
auto dst = ColumnArray::create(ColumnUInt64::create());
96+
auto & dst_data = typeid_cast<ColumnUInt64 &>(dst->getData());
97+
auto & dst_offsets = dst->getOffsets();
98+
dst_offsets.resize(input_rows_count);
99+
100+
/// First calculate array sizes for all rows and save them in Offsets
101+
UInt64 current_offset = 0;
102+
for (size_t row = 0; row < input_rows_count; ++row)
103+
{
104+
const int k = data_k[row];
105+
106+
/// The result size is 6*k. We should not allow to generate too large arrays nevertheless.
107+
constexpr auto max_k = 10000;
108+
if (k > max_k)
109+
throw Exception(ErrorCodes::PARAMETER_OUT_OF_BOUND, "Too large 'k' argument for {} function, maximum {}", getName(), max_k);
110+
/// Check is already made while fetching the argument for k (to determine if it's an unsigned integer). Nevertheless, it's checked again here.
111+
if (k < 0)
112+
throw Exception(ErrorCodes::PARAMETER_OUT_OF_BOUND, "Argument 'k' for {} function must be non negative", getName());
113+
114+
const auto vec_size = (k == 0 ? 1 : 6 * k); /// Required size according to comments in gridRingUnsafe() source code
115+
116+
current_offset += vec_size;
117+
dst_offsets[row] = current_offset;
118+
}
119+
120+
/// Allocate based on total size of arrays for all rows
121+
dst_data.getData().resize(current_offset);
122+
123+
/// Fill the array for each row with known size
124+
auto* ptr = dst_data.getData().data();
125+
current_offset = 0;
126+
for (size_t row = 0; row < input_rows_count; ++row)
127+
{
128+
const H3Index origin_hindex = data_hindex[row];
129+
const int k = data_k[row];
130+
131+
H3Error err = gridRingUnsafe(origin_hindex, k, ptr + current_offset);
132+
133+
if (err)
134+
throw Exception(ErrorCodes::INCORRECT_DATA, "Incorrect arguments h3Index: {}, k: {}, error: {}", origin_hindex, k, err);
135+
136+
const auto size = dst_offsets[row] - current_offset;
137+
current_offset += size;
138+
}
139+
140+
return dst;
141+
}
142+
};
143+
144+
}
145+
146+
void registerFunctionH3HexRing(FunctionFactory & factory)
147+
{
148+
factory.registerFunction<FunctionH3HexRing>();
149+
}
150+
151+
}
152+
153+
#endif

‎src/Functions/h3Line.cpp

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#include "config_functions.h"
2+
3+
#if USE_H3
4+
5+
#include <Columns/ColumnArray.h>
6+
#include <Columns/ColumnsNumber.h>
7+
#include <DataTypes/DataTypeArray.h>
8+
#include <DataTypes/DataTypesNumber.h>
9+
#include <Functions/FunctionFactory.h>
10+
#include <Functions/IFunction.h>
11+
#include <Common/typeid_cast.h>
12+
#include <IO/WriteHelpers.h>
13+
#include <base/range.h>
14+
15+
#include <constants.h>
16+
#include <h3api.h>
17+
18+
19+
namespace DB
20+
{
21+
namespace ErrorCodes
22+
{
23+
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
24+
extern const int ILLEGAL_COLUMN;
25+
extern const int INCORRECT_DATA;
26+
}
27+
28+
namespace
29+
{
30+
31+
class FunctionH3Line : public IFunction
32+
{
33+
public:
34+
static constexpr auto name = "h3Line";
35+
36+
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionH3Line>(); }
37+
38+
std::string getName() const override { return name; }
39+
40+
size_t getNumberOfArguments() const override { return 2; }
41+
bool useDefaultImplementationForConstants() const override { return true; }
42+
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
43+
44+
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
45+
{
46+
const auto * arg = arguments[0].get();
47+
if (!WhichDataType(arg).isUInt64())
48+
throw Exception(
49+
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
50+
"Illegal type {} of argument {} of function {}. Must be UInt64",
51+
arg->getName(), 1, getName());
52+
53+
arg = arguments[1].get();
54+
if (!WhichDataType(arg).isUInt64())
55+
throw Exception(
56+
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
57+
"Illegal type {} of argument {} of function {}. Must be UInt64",
58+
arg->getName(), 2, getName());
59+
60+
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>());
61+
}
62+
63+
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override
64+
{
65+
auto non_const_arguments = arguments;
66+
for (auto & argument : non_const_arguments)
67+
argument.column = argument.column->convertToFullColumnIfConst();
68+
69+
const auto * col_start_index = checkAndGetColumn<ColumnUInt64>(non_const_arguments[0].column.get());
70+
if (!col_start_index)
71+
throw Exception(
72+
ErrorCodes::ILLEGAL_COLUMN,
73+
"Illegal type {} of argument {} of function {}. Must be UInt64.",
74+
arguments[0].type->getName(),
75+
1,
76+
getName());
77+
78+
const auto & data_start_index = col_start_index->getData();
79+
80+
const auto * col_end_index = checkAndGetColumn<ColumnUInt64>(non_const_arguments[1].column.get());
81+
if (!col_end_index)
82+
throw Exception(
83+
ErrorCodes::ILLEGAL_COLUMN,
84+
"Illegal type {} of argument {} of function {}. Must be UInt64.",
85+
arguments[1].type->getName(),
86+
2,
87+
getName());
88+
89+
const auto & data_end_index = col_end_index->getData();
90+
91+
92+
auto dst = ColumnArray::create(ColumnUInt64::create());
93+
auto & dst_data = typeid_cast<ColumnUInt64 &>(dst->getData());
94+
auto & dst_offsets = dst->getOffsets();
95+
dst_offsets.resize(input_rows_count);
96+
97+
/// First calculate array sizes for all rows and save them in Offsets
98+
UInt64 current_offset = 0;
99+
for (size_t row = 0; row < input_rows_count; ++row)
100+
{
101+
const UInt64 start = data_start_index[row];
102+
const UInt64 end = data_end_index[row];
103+
104+
auto size = gridPathCellsSize(start, end);
105+
if (size < 0)
106+
throw Exception(
107+
ErrorCodes::INCORRECT_DATA,
108+
"Line cannot be computed between start H3 index {} and end H3 index {}",
109+
start, end);
110+
111+
current_offset += size;
112+
dst_offsets[row] = current_offset;
113+
}
114+
115+
/// Allocate based on total size of arrays for all rows
116+
dst_data.getData().resize(current_offset);
117+
118+
/// Fill the array for each row with known size
119+
auto* ptr = dst_data.getData().data();
120+
current_offset = 0;
121+
for (size_t row = 0; row < input_rows_count; ++row)
122+
{
123+
const UInt64 start = data_start_index[row];
124+
const UInt64 end = data_end_index[row];
125+
const auto size = dst_offsets[row] - current_offset;
126+
gridPathCells(start, end, ptr + current_offset);
127+
current_offset += size;
128+
}
129+
130+
return dst;
131+
}
132+
};
133+
134+
}
135+
136+
void registerFunctionH3Line(FunctionFactory & factory)
137+
{
138+
factory.registerFunction<FunctionH3Line>();
139+
}
140+
141+
}
142+
143+
#endif

‎src/Functions/registerFunctionsGeo.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ void registerFunctionH3PointDistKm(FunctionFactory &);
5757
void registerFunctionH3PointDistRads(FunctionFactory &);
5858
void registerFunctionH3GetRes0Indexes(FunctionFactory &);
5959
void registerFunctionH3GetPentagonIndexes(FunctionFactory &);
60+
void registerFunctionH3Line(FunctionFactory &);
61+
void registerFunctionH3Distance(FunctionFactory &);
62+
void registerFunctionH3HexRing(FunctionFactory &);
6063

6164
#endif
6265

@@ -128,6 +131,9 @@ void registerFunctionsGeo(FunctionFactory & factory)
128131
registerFunctionH3PointDistRads(factory);
129132
registerFunctionH3GetRes0Indexes(factory);
130133
registerFunctionH3GetPentagonIndexes(factory);
134+
registerFunctionH3Line(factory);
135+
registerFunctionH3Distance(factory);
136+
registerFunctionH3HexRing(factory);
131137
#endif
132138

133139
#if USE_S2_GEOMETRY

‎tests/queries/0_stateless/01659_h3_buffer_overflow.sql

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ SELECT h3GetBaseCell(0xFFFFFFFFFFFFFF) FORMAT Null;
1010
SELECT h3GetResolution(0xFFFFFFFFFFFFFF) FORMAT Null;
1111
SELECT h3kRing(0xFFFFFFFFFFFFFF, toUInt16(10)) FORMAT Null;
1212
SELECT h3ToGeo(0xFFFFFFFFFFFFFF) FORMAT Null;
13+
SELECT h3HexRing(0xFFFFFFFFFFFFFF, toUInt16(10)) FORMAT Null; -- { serverError 117 }
14+
SELECT h3HexRing(0xFFFFFFFFFFFFFF, toUInt16(10000)) FORMAT Null; -- { serverError 117 }
15+
SELECT length(h3HexRing(581276613233082367, toUInt16(1))) FORMAT Null;

‎tests/queries/0_stateless/02223_h3_test_const_columns.reference

+4
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@
7878
842
7979
5882
8080
41162
81+
[599686042433355775,599686043507097599,599686023106002943]
82+
[581276613233082367]
83+
[581518505791193087,581500913605148671,581764796395814911,581259021047037951,581250224954015743,581267817140060159]
84+
[581514107744681983,581496515558637567,581509709698170879,581760398349303807,581742806163259391,581747204209770495,581549292116770815,581263419093549055,581254623000526847,581272215186571263,581122681605193727,581118283558682623]

‎tests/queries/0_stateless/02223_h3_test_const_columns.sql

+3
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ SELECT h3ExactEdgeLengthM(arrayJoin([1298057039473278975,1370114633511206911,144
2929
SELECT h3ExactEdgeLengthKm(arrayJoin([1298057039473278975,1370114633511206911,1442172227549134847,1514229821587062783]));
3030
SELECT h3ExactEdgeLengthRads(arrayJoin([1298057039473278975,1370114633511206911,1442172227549134847,1514229821587062783]));
3131
SELECT h3NumHexagons(arrayJoin([1,2,3]));
32+
SELECT h3Line(arrayJoin([stringToH3('85283473fffffff')]), arrayJoin([stringToH3('8528342bfffffff')]));
33+
SELECT h3HexRing(arrayJoin([579205133326352383]), arrayJoin([toUInt16(1),toUInt16(2),toUInt16(3)])); -- { serverError 117 }
34+
SELECT h3HexRing(arrayJoin([581276613233082367]), arrayJoin([toUInt16(0),toUInt16(1),toUInt16(2)]));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
7
2+
7
3+
7
4+
7
5+
7
6+
7
7+
7
8+
7
9+
7
10+
7
11+
8
12+
9
13+
9
14+
9
15+
9
16+
9
17+
9
18+
9
19+
9
20+
9
21+
13
22+
13
23+
13
24+
13
25+
13
26+
13
27+
13
28+
13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-- Tags: no-fasttest
2+
3+
DROP TABLE IF EXISTS h3_indexes;
4+
5+
CREATE TABLE h3_indexes (id int, start String, end String) ENGINE = Memory;
6+
7+
-- test values taken from h3 library test suite
8+
9+
INSERT INTO h3_indexes VALUES (1, '830631fffffffff','830780fffffffff');
10+
INSERT INTO h3_indexes VALUES (2, '830631fffffffff','830783fffffffff');
11+
INSERT INTO h3_indexes VALUES (3, '830631fffffffff','83079dfffffffff');
12+
INSERT INTO h3_indexes VALUES (4, '830631fffffffff','830799fffffffff');
13+
INSERT INTO h3_indexes VALUES (5, '830631fffffffff','8306f5fffffffff');
14+
INSERT INTO h3_indexes VALUES (6, '830631fffffffff','8306e6fffffffff');
15+
INSERT INTO h3_indexes VALUES (7, '830631fffffffff','8306e4fffffffff');
16+
INSERT INTO h3_indexes VALUES (8, '830631fffffffff','830701fffffffff');
17+
INSERT INTO h3_indexes VALUES (9, '830631fffffffff','830700fffffffff');
18+
INSERT INTO h3_indexes VALUES (10, '830631fffffffff','830706fffffffff');
19+
INSERT INTO h3_indexes VALUES (11, '830631fffffffff','830733fffffffff');
20+
INSERT INTO h3_indexes VALUES (12, '8301a6fffffffff','830014fffffffff');
21+
INSERT INTO h3_indexes VALUES (13, '8301a6fffffffff','830033fffffffff');
22+
INSERT INTO h3_indexes VALUES (14, '8301a6fffffffff','830031fffffffff');
23+
INSERT INTO h3_indexes VALUES (15, '8301a6fffffffff','830022fffffffff');
24+
INSERT INTO h3_indexes VALUES (16, '8301a6fffffffff','830020fffffffff');
25+
INSERT INTO h3_indexes VALUES (17, '8301a6fffffffff','830024fffffffff');
26+
INSERT INTO h3_indexes VALUES (18, '8301a6fffffffff','830120fffffffff');
27+
INSERT INTO h3_indexes VALUES (19, '8301a6fffffffff','830124fffffffff');
28+
INSERT INTO h3_indexes VALUES (20, '8301a6fffffffff','8308cdfffffffff');
29+
INSERT INTO h3_indexes VALUES (21, '8301a5fffffffff','831059fffffffff');
30+
INSERT INTO h3_indexes VALUES (22, '8301a5fffffffff','830b2dfffffffff');
31+
INSERT INTO h3_indexes VALUES (23, '8301a5fffffffff','830b29fffffffff');
32+
INSERT INTO h3_indexes VALUES (24, '8301a5fffffffff','830b76fffffffff');
33+
INSERT INTO h3_indexes VALUES (25, '8301a5fffffffff','830b43fffffffff');
34+
INSERT INTO h3_indexes VALUES (26, '8301a5fffffffff','830b4efffffffff');
35+
INSERT INTO h3_indexes VALUES (27, '8301a5fffffffff','830b48fffffffff');
36+
INSERT INTO h3_indexes VALUES (28, '8301a5fffffffff','830b49fffffffff');
37+
38+
39+
SELECT h3Distance(stringToH3(start), stringToH3(end)) FROM h3_indexes ORDER BY id;
40+
41+
42+
DROP TABLE h3_indexes;
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[581276613233082367]
2+
[580995138256371711,581144671837749247,581166662070304767,581171060116815871,581267817140060159,581272215186571263,581276613233082367,581531699930726399,581536097977237503,581558088209793023,581747204209770495,581764796395814911]
3+
[581250224954015743,581259021047037951,581267817140060159,581500913605148671,581518505791193087,581764796395814911]
4+
[589624655266971647,589625205022785535,589626854290227199,589642797208829951,589644996232085503,589708767906496511,589709317662310399,589709867418124287,589714815220449279,589715914732077055,589725810336727039,589727459604168703,589728009359982591,589735156185563135,589736255697190911,589742303011143679,589744502034399231,589745051790213119]
5+
[594053281945223167,594053419384176639,594054106578943999,594054244017897471,594054450176327679,594055343529525247,594055618407432191,594064277061500927,594064345780977663,594071698764988415,594071767484465151,594072111081848831,594072317240279039,594072523398709247,594072592118185983,594079532785336319,594079807663243263,594081044613824511,594081113333301247,594081319491731455,594081594369638399,594081731808591871,594081937967022079,594082762600742911]
6+
[598346591383846911,598346814722146303,598346840491950079,598346849081884671,598346960751034367,598346977930903551,598348884896382975,598348910666186751,598348919256121343,598349168364224511,598349176954159103,598356710326796287,598356718916730879,598356761866403839,598356779046273023,598356796226142207,598356821995945983,598371905921089535,598371923100958719,598372687605137407,598372704785006591,598372807864221695,598372842223960063,598373580958334975,598373589548269567,598373830066438143,598373864426176511,598374783549177855,598374792139112447,598374800729047039]
7+
[599542260886929407,599542265181896703,599542294172925951,599542297394151423,599542298467893247,599542329606406143,599542330680147967,599542331753889791,599542337122598911,599542338196340735,599542343565049855,599542350007500799,599542351081242623,599542599115603967,599542601263087615,599542612000505855,599542614147989503,599542617369214975,599542630254116863,599542632401600511,599542642065276927,599542643139018751,599547512558190591,599547514705674239,599547525443092479,599547527590576127,599547530811801599,599549536561528831,599549540856496127,599549546225205247,599549550520172543,599549569847525375,599549573068750847,599549576289976319,599549838282981375,599549839356723199]
8+
[604296028669083647,604296029205954559,604296036587929599,604296036722147327,604296037124800511,604296037259018239,604296037930106879,604296273348001791,604296273750654975,604296273884872703,604296277777186815,604296333477543935,604296333880197119,604296334014414847,604296337235640319,604296337369858047,604296337772511231,604296337906728959,604296338577817599,604296347704623103,604296348241494015,604296351999590399,604296352133808127,604296356294557695,604296356831428607,604296358173605887,604296358442041343,604296358844694527,604296360857960447,604296361126395903,604296363676532735,604296363944968191,604296364213403647,604296369179459583,604296369313677311,604296383943409663,604296384211845119,604296384614498303,604296386627764223,604296386896199679,604296389446336511,604296389714771967]
9+
[608784291018571775,608784291035348991,608784291119235071,608784291136012287,608784291219898367,608784292931174399,608784292964728831,608784293132500991,608784293166055423,608784293216387071,608784293417713663,608784293451268095,608785191854407679,608785191904739327,608785191921516543,608785192424833023,608785192491941887,608785193750233087,608785193783787519,608785194203217919,608785194236772351,608785194404544511,608785194438098943,608785194488430591,608785196182929407,608785196199706623,608785198632402943,608785198649180159,608785198716289023,608785198783397887,608785209319489535,608785209386598399,608785209436930047,608785209453707263,608785209537593343,608785210410008575,608785210426785791,608785210510671871,608785210594557951,608785210611335167,608785210711998463,608785210728775679,608785213195026431,608785213245358079,608785213262135295,608785213614456831,608785213765451775,608785213832560639]
10+
[615732152056676351,615732152062967807,615732152065064959,615732152115396607,615732152117493759,615732152125882367,615732152134270975,615732152593547263,615732152599838719,615732152601935871,615732152648073215,615732152656461823,615732152677433343,615732152681627647,615732152687919103,615732189809606655,615732191669780479,615732191673974783,615732191678169087,615732191701237759,615732191705432063,615732191711723519,615732191923535871,615732191925633023,615732191938215935,615732191942410239,615732191978061823,615732191980158975,615732192020004863,615732192022102015,615732192032587775,615732192129056767,615732192133251071,615732192206651391,615732192215039999,615732192263274495,615732192265371647,615732192271663103,615732192273760255,615732192284246015,615732192359743487,615732192368132095,615732192422658047,615732192428949503,615732192431046655,615732196117839871,615732196119937023,615732196356915199,615732196361109503,615732196432412671,615732196434509823,615732196436606975,615732196451287039,615732196455481343]
11+
[617056792082120703,617056792083169279,617056793998917631,617056793999179775,617056794000490495,617056794000752639,617056794002063359,617056794003636223,617056794003898367,617056794015170559,617056794015694847,617056794016481279,617056794020413439,617056794020675583,617056794478903295,617056794479951871,617056794487029759,617056794487816191,617056794488078335,617056794497515519,617056794498301951,617056794498564095,617056794506428415,617056794507476991,617056794527924223,617056794528186367,617056794528448511,617056794531069951,617056794531594239,617056794532380671,617056794537885695,617056794538147839,617056794544701439,617056794544963583,617056794546012159,617056794547060735,617056794554662911,617056794554925055,617056794556235775,617056794556497919,617056794557808639,617056794561478655,617056794562002943,617056794564624383,617056794565410815,617056794565935103,617056794569080831,617056794569605119,617056794666860543,617056794699890687,617056794700414975,617056794703036415,617056794703560703,617056794704347135,617056794707492863,617056794708017151,617056794755727359,617056794756775935,617056794822836223,617056794823884799]
12+
[624586471612907519,624586471613005823,624586471613038591,624586471613759487,624586471613890559,624586471613988863,624586471614119935,624586471619330047,624586471619395583,624586471620280319,624586471620411391,624586471620804607,624586471620870143,624586471621951487,624586471621984255,624586471622148095,624586471622279167,624586471622934527,624586471622967295,624586471647903743,624586471647936511,624586471655374847,624586471655407615,624586471655571455,624586471655702527,624586471655735295,624586471657078783,624586471657144319,624586471658258431,624586471658323967,624586471658422271,624586471658553343,624586471658618879,624586471660486655,624586471660519423,624586475478614015,624586475478646783,624586475478745087,624586475478777855,624586475478941695,624586475479597055,624586475479629823,624586477870874623,624586477871005695,624586477871366143,624586477871497215,624586477871890431,624586477871955967,624586477872250879,624586477872316415,624586477877166079,624586477877297151,624586477877657599,624586477877788671,624586477877952511,624586477877985279,624586477878149119,624586477878247423,624586477878280191,624586477882376191,624586477882441727,624586477882736639,624586477882802175,624586477882867711,624586477882933247,624586477883031551]
13+
[627882919482134527,627882919482138623,627882919482159103,627882919482200063,627882919482208255,627882919482220543,627882919482675199,627882919482683391,627882919482724351,627882919482732543,627882919482744831,627882919482793983,627882919482802175,627882919484207103,627882919484223487,627882919484297215,627882919484309503,627882919484313599,627882919484399615,627882919484415999,627882919484993535,627882919484997631,627882919485018111,627882919485022207,627882919485042687,627882919485067263,627882919485071359,627882919485255679,627882919485329407,627882919485333503,627882919485345791,627882919485358079,627882919485362175,627882919521722367,627882919521738751,627882919521849343,627882919521861631,627882919521865727,627882919522021375,627882919522037759,627882919522054143,627882919522058239,627882919522652159,627882919522656255,627882919522770943,627882919522787327,627882919522902015,627882919522910207,627882919523069951,627882919523086335,627882919538020351,627882919538028543,627882919538139135,627882919538147327,627882919538155519,627882919540690943,627882919540711423,627882919540715519,627882919541714943,627882919541719039,627882919541952511,627882919541960703,627882919542001663,627882919542009855,627882919542022143,627882919542071295,627882919542079487,627882919542263807,627882919542267903,627882919542288383,627882919542312959,627882919542317055]
14+
[634600058495592959,634600058495593983,634600058495648255,634600058495649279,634600058495650815,634600058495658495,634600058495659519,634600058503304191,634600058503306239,634600058503341567,634600058503343615,634600058503356927,634600058503358463,634600058503358975,634600058503402495,634600058503404543,634600058503410687,634600058503411711,634600058503431679,634600058503432191,634600058503444991,634600058503445503,634600058503455231,634600058503455743,634600058503458303,634600058503472639,634600058503474687,634600058503487999,634600058503489535,634600058503491071,634600058504447487,634600058504447999,634600058504460799,634600058504461311,634600058504471551,634600058504472575,634600058507233791,634600058507234303,634600058507235839,634600058507236351,634600058507238911,634600058507249151,634600058507249663,634600058507280895,634600058507281919,634600058507283455,634600058507408383,634600058507409407,634600058507430399,634600058507430911,634600058507432447,634600058507432959,634600058507435519,634600058507444735,634600058507446271,634600058507446783,634600058508281343,634600058508282367,634600058508283391,634600058508289023,634600058508291071,634600058508300799,634600058508301823,634600058508303359,634600058508379647,634600058508381695,634600058508387327,634600058508389375,634600058508395007,634600058508396543,634600058508397055,634600058508446207,634600058508447231,634600058508464639,634600058508465663,634600058508467199,634600058508469247,634600058508470271]
15+
[635544851676508863,635544851676508927,635544851676509247,635544851676509311,635544851676509375,635544851676510015,635544851676510079,635544851676961407,635544851676961663,635544851676977791,635544851676978047,635544851677184319,635544851677184447,635544851677185087,635544851677185215,635544851677185407,635544851677186175,635544851677186303,635544851677192511,635544851677192639,635544851677193279,635544851677193599,635544851677193663,635544851677194367,635544851677194495,635544851677203071,635544851677203327,635544851677205567,635544851677205695,635544851677205823,635544851677207743,635544851677207999,635544851677266623,635544851677266687,635544851677267007,635544851677267071,635544851677267263,635544851677267775,635544851677267839,635544851677269183,635544851677269439,635544851677270719,635544851677270783,635544851677271103,635544851677271167,635544851677271487,635544851677271871,635544851677271935,635544851677316159,635544851677316351,635544851677316543,635544851677325951,635544851677326207,635544851677328447,635544851677328639,635544851677328703,635544851677330623,635544851677330879,635544851677340351,635544851677340415,635544851677340735,635544851677340799,635544851677341119,635544851677341503,635544851677341567,635544851677389887,635544851677390079,635544851677390143,635544851677392063,635544851677392319,635544851677397311,635544851677397439,635544851677398079,635544851677398207,635544851677398399,635544851677399167,635544851677399295,635544851677405503,635544851677405631,635544851677406271,635544851677406463,635544851677406591,635544851677407359,635544851677407487]
16+
[639763125756235855,639763125756235887,639763125756236439,639763125756236471,639763125756236679,639763125756236703,639763125756236711,639763125756237391,639763125756237423,639763125756238487,639763125756238519,639763125756238599,639763125756238615,639763125756238639,639763125756238727,639763125756238751,639763125756238759,639763125756266535,639763125756266551,639763125756266823,639763125756266839,639763125756266863,639763125756266895,639763125756266911,639763125756267559,639763125756267575,639763125756267847,639763125756267863,639763125756267887,639763125756267911,639763125756267919,639763125756267959,639763125756286007,639763125756286215,639763125756286239,639763125756286247,639763125756286351,639763125756286367,639763125756288023,639763125756288055,639763125756288143,639763125756288175,639763125756288263,639763125756288287,639763125756288295,639763125756291095,639763125756291103,639763125756291303,639763125756291311,639763125756291463,639763125756291471,639763125756291495,639763125756291607,639763125756291615,639763125756291815,639763125756291823,639763125756291975,639763125756291983,639763125756292023,639763125756403919,639763125756403935,639763125756404263,639763125756404271,639763125756404295,639763125756404303,639763125756404343,639763125756404503,639763125756404511,639763125756404647,639763125756404663,639763125756404943,639763125756404959,639763125756405511,639763125756405527,639763125756405551,639763125756405671,639763125756405687,639763125756408871,639763125756408879,639763125756408903,639763125756408911,639763125756408951,639763125756409111,639763125756409119,639763125756409367,639763125756409399,639763125756409487,639763125756409519,639763125756409623,639763125756409631]
17+
[644178757620498449,644178757620498453,644178757620498458,644178757620498462,644178757620498480,644178757620498483,644178757620498484,644178757620498628,644178757620498629,644178757620498666,644178757620498667,644178757620498672,644178757620498673,644178757620498676,644178757620498705,644178757620498709,644178757620498714,644178757620498718,644178757620498736,644178757620498739,644178757620498740,644178757620498948,644178757620498977,644178757620498979,644178757620498992,644178757620498993,644178757620498998,644178757620499268,644178757620499270,644178757620499280,644178757620499282,644178757620499285,644178757620499297,644178757620499299,644178757620499332,644178757620499333,644178757620499370,644178757620499371,644178757620499376,644178757620499377,644178757620499382,644178757620500492,644178757620500494,644178757620500504,644178757620500506,644178757620500509,644178757620500521,644178757620500523,644178757620500620,644178757620500622,644178757620500632,644178757620500634,644178757620500637,644178757620500649,644178757620500651,644178757620500810,644178757620500811,644178757620500824,644178757620500826,644178757620500829,644178757620501064,644178757620501067,644178757620501068,644178757620501089,644178757620501093,644178757620501098,644178757620501102,644178757620501320,644178757620501323,644178757620501324,644178757620501345,644178757620501349,644178757620501354,644178757620501358,644178757620505988,644178757620505990,644178757620506000,644178757620506002,644178757620506005,644178757620506017,644178757620506019,644178757620506021,644178757620520074,644178757620520075,644178757620520080,644178757620520081,644178757620520086,644178757620520092,644178757620520093,644178757620520138,644178757620520139,644178757620520144,644178757620520145,644178757620520150,644178757620520156,644178757620520157]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Tags: no-fasttest
2+
3+
SELECT h3HexRing(581276613233082367, toUInt16(0));
4+
SELECT h3HexRing(579205132326352334, toUInt16(1)) as hexRing; -- { serverError 117 }
5+
SELECT h3HexRing(581276613233082367, -1); -- { serverError 43 }
6+
SELECT h3HexRing(581276613233082367, toUInt16(-1)); -- { serverError 12 }
7+
8+
DROP TABLE IF EXISTS h3_indexes;
9+
10+
-- Test h3 indices and k selected from original test fixture: https://github.com/uber/h3/blob/master/src/apps/testapps
11+
12+
CREATE TABLE h3_indexes (h3_index UInt64, k UInt16) ENGINE = Memory;
13+
14+
15+
INSERT INTO h3_indexes VALUES (581276613233082367,1);
16+
INSERT INTO h3_indexes VALUES (581263419093549055,2);
17+
INSERT INTO h3_indexes VALUES (589753847883235327,3);
18+
INSERT INTO h3_indexes VALUES (594082350283882495,4);
19+
INSERT INTO h3_indexes VALUES (598372386957426687,5);
20+
INSERT INTO h3_indexes VALUES (599542359671177215,6);
21+
INSERT INTO h3_indexes VALUES (604296355086598143,7);
22+
INSERT INTO h3_indexes VALUES (608785214872748031,8);
23+
INSERT INTO h3_indexes VALUES (615732192485572607,9);
24+
INSERT INTO h3_indexes VALUES (617056794467368959,10);
25+
INSERT INTO h3_indexes VALUES (624586477873168383,11);
26+
INSERT INTO h3_indexes VALUES (627882919484481535,12);
27+
INSERT INTO h3_indexes VALUES (634600058503392255,13);
28+
INSERT INTO h3_indexes VALUES (635544851677385791,14);
29+
INSERT INTO h3_indexes VALUES (639763125756281263,15);
30+
INSERT INTO h3_indexes VALUES (644178757620501158,16);
31+
32+
33+
SELECT arraySort(h3HexRing(h3_index, k)) FROM h3_indexes ORDER BY h3_index;
34+
35+
DROP TABLE h3_indexes;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[590080540275638271,590080471556161535,590080883873021951,590106516237844479,590104385934065663,590103630019821567,590103561300344831]
2+
[590080540275638271,590080471556161535,590080608995115007,590104454653542399,590104385934065663,590104523373019135,590103767458775039]
3+
[590080540275638271,590080471556161535,590080608995115007,590104454653542399,590104111056158719,590104523373019135,590105554165170175]
4+
[590080540275638271,590080677714591743,590080608995115007,590104179775635455,590104317214588927,590104248495112191,590105279287263231]
5+
[590080540275638271,590077585338138623,590077310460231679,590079097166626815,590078822288719871,590079028447150079,590094009293078527]
6+
[590080540275638271,590077585338138623,590077310460231679,590079097166626815,590079165886103551,590078891008196607,590092978500927487]
7+
[590080540275638271,590077585338138623,590077173021278207,590077379179708415,590079165886103551,590077860216045567,590092841061974015]
8+
[590080540275638271,590080815153545215,590079784361394175,590096483194241023,590096758072147967,590095727279996927,590094833926799359]
9+
[590080540275638271,590080815153545215,590096620633194495,590096414474764287,590096758072147967,590094971365752831,590094765207322623]
10+
[590080540275638271,590080815153545215,590096620633194495,590096414474764287,590096689352671231,590094902646276095,590095177524183039]
11+
[590080540275638271,590080815153545215,590096620633194495,590096414474764287,590096826791624703,590095933438427135,590096208316334079,590098269900636159]
12+
[590000619524194303,590000344646287359,590000413365764095,589998351781462015,590000894402101247,589998832817799167,589998901537275903,589998626659368959,589972994294546431]
13+
[590000619524194303,590000207207333887,590000413365764095,590001169280008191,590000894402101247,590000963121577983,589975330756755455,589975055878848511,589975124598325247]
14+
[590000619524194303,590000207207333887,590000413365764095,590001169280008191,590000756963147775,590000825682624511,589975330756755455,589974918439895039,589974987159371775]
15+
[590000619524194303,590000207207333887,590000275926810623,590001031841054719,590000756963147775,590000825682624511,589975193317801983,589975262037278719,589973956367220735]
16+
[590000619524194303,590000207207333887,590000275926810623,590001031841054719,590001100560531455,589990998797451263,589991067516927999,589974231245127679,589973818928267263]
17+
[590000619524194303,590000207207333887,590000275926810623,590001031841054719,589990517761114111,589991273675358207,589990861358497791,589990930077974527,589974093806174207]
18+
[590000619524194303,590000482085240831,590277902612824063,590278177490731007,589992648064892927,589992716784369663,589992579345416191,589991548553265151,589991411114311679]
19+
[590000619524194303,590000482085240831,590277902612824063,590278177490731007,589992648064892927,589992510625939455,589992854223323135,589991823431172095,589991685992218623]
20+
[590000619524194303,590000482085240831,590277902612824063,590278177490731007,590278108771254271,589992922942799871,589992785503846399,590126170008190975,590126444886097919]
21+
[590000550804717567,590000207207333887,590000619524194303,590001650316345343,590001581596868607,590001719035822079,590259760670965759,590260654024163327,590260379146256383,590257561647710207,590258455000907775,590259485793058815,590259210915151871]
22+
[590000550804717567,590000207207333887,590000619524194303,590001650316345343,590001306718961663,590001719035822079,590260516585209855,590260241707302911,590260379146256383,590258317561954303,590258042684047359,590258180123000831,590168226327953407]
23+
[590000550804717567,590000207207333887,590000619524194303,590001650316345343,590001306718961663,590001444157915135,590260516585209855,590260241707302911,590260447865733119,590258386281431039,590258042684047359,590258248842477567,590167951450046463]
24+
[590000550804717567,590000207207333887,590000344646287359,590001650316345343,590001306718961663,590001444157915135,590260585304686591,590260310426779647,590172005899173887,590258386281431039,590258111403524095,590173105410801663,590173242849755135]
25+
[590000550804717567,590000207207333887,590000344646287359,589998283061985279,589998420500938751,589999451293089791,589999107695706111,589999313854136319,590172555654987775,590172693093941247,590169875595395071,590169600717488127,590169738156441599]
26+
[590000550804717567,590000207207333887,590000413365764095,589998283061985279,589998420500938751,589998145623031807,589999176415182847,589999313854136319,590172624374464511,590172280777080831,590172418216034303,590170356631732223,590170494070685695]
27+
[590000550804717567,590000207207333887,590000413365764095,589998283061985279,589998008184078335,589998145623031807,589999176415182847,590000069768380415,590172624374464511,590172349496557567,590172486935511039,590170425351208959,590170081753825279]
28+
[590000550804717567,590000207207333887,590000413365764095,589998283061985279,589998008184078335,589998145623031807,589999932329426943,590000069768380415,589999794890473471,590172349496557567,589984126849777663,590170425351208959,590170150473302015]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
-- Tags: no-fasttest
2+
3+
DROP TABLE IF EXISTS h3_indexes;
4+
5+
CREATE TABLE h3_indexes (id int, start String, end String) ENGINE = Memory;
6+
7+
-- test values taken from h3 library test suite
8+
9+
INSERT INTO h3_indexes VALUES (1, '830631fffffffff','830780fffffffff');
10+
INSERT INTO h3_indexes VALUES (2, '830631fffffffff','830783fffffffff');
11+
INSERT INTO h3_indexes VALUES (3, '830631fffffffff','83079dfffffffff');
12+
INSERT INTO h3_indexes VALUES (4, '830631fffffffff','830799fffffffff');
13+
INSERT INTO h3_indexes VALUES (5, '830631fffffffff','8306f5fffffffff');
14+
INSERT INTO h3_indexes VALUES (6, '830631fffffffff','8306e6fffffffff');
15+
INSERT INTO h3_indexes VALUES (7, '830631fffffffff','8306e4fffffffff');
16+
INSERT INTO h3_indexes VALUES (8, '830631fffffffff','830701fffffffff');
17+
INSERT INTO h3_indexes VALUES (9, '830631fffffffff','830700fffffffff');
18+
INSERT INTO h3_indexes VALUES (10, '830631fffffffff','830706fffffffff');
19+
INSERT INTO h3_indexes VALUES (11, '830631fffffffff','830733fffffffff');
20+
INSERT INTO h3_indexes VALUES (12, '8301a6fffffffff','830014fffffffff');
21+
INSERT INTO h3_indexes VALUES (13, '8301a6fffffffff','830033fffffffff');
22+
INSERT INTO h3_indexes VALUES (14, '8301a6fffffffff','830031fffffffff');
23+
INSERT INTO h3_indexes VALUES (15, '8301a6fffffffff','830022fffffffff');
24+
INSERT INTO h3_indexes VALUES (16, '8301a6fffffffff','830020fffffffff');
25+
INSERT INTO h3_indexes VALUES (17, '8301a6fffffffff','830024fffffffff');
26+
INSERT INTO h3_indexes VALUES (18, '8301a6fffffffff','830120fffffffff');
27+
INSERT INTO h3_indexes VALUES (19, '8301a6fffffffff','830124fffffffff');
28+
INSERT INTO h3_indexes VALUES (20, '8301a6fffffffff','8308cdfffffffff');
29+
INSERT INTO h3_indexes VALUES (21, '8301a5fffffffff','831059fffffffff');
30+
INSERT INTO h3_indexes VALUES (22, '8301a5fffffffff','830b2dfffffffff');
31+
INSERT INTO h3_indexes VALUES (23, '8301a5fffffffff','830b29fffffffff');
32+
INSERT INTO h3_indexes VALUES (24, '8301a5fffffffff','830b76fffffffff');
33+
INSERT INTO h3_indexes VALUES (25, '8301a5fffffffff','830b43fffffffff');
34+
INSERT INTO h3_indexes VALUES (26, '8301a5fffffffff','830b4efffffffff');
35+
INSERT INTO h3_indexes VALUES (27, '8301a5fffffffff','830b48fffffffff');
36+
INSERT INTO h3_indexes VALUES (28, '8301a5fffffffff','830b49fffffffff');
37+
38+
39+
SELECT h3Line(stringToH3(start), stringToH3(end)) FROM h3_indexes ORDER BY id;
40+
41+
SELECT h3Line(0xffffffffffffff, 0xffffffffffffff); -- { serverError 117 }
42+
43+
DROP TABLE h3_indexes;
44+

0 commit comments

Comments
 (0)
Please sign in to comment.