Skip to content

Commit ce87f9c

Browse files
authored
Merge pull request ClickHouse#80544 from ClickHouse/ncb/rename-geotoh3_lon_lat_input_order
better name for geotoh3_lon_lat_input_order
2 parents 955efa8 + 766d77b commit ce87f9c

File tree

9 files changed

+30
-14
lines changed

9 files changed

+30
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
### <a id="255"></a> ClickHouse release 25.5, 2025-05-22
1919

2020
#### Backward Incompatible Change
21-
* Function `geoToH3` now accepts the input in the order (lat, lon, res) (which is common for other geometric functions). Users who wish to retain the previous result order (lon, lat, res) can set setting `geotoh3_lon_lat_input_order = true`. [#78852](https://github.com/ClickHouse/ClickHouse/pull/78852) ([Pratima Patel](https://github.com/pratimapatel2008)).
21+
* Function `geoToH3` now accepts the input in the order (lat, lon, res) (which is common for other geometric functions). Users who wish to retain the previous result order (lon, lat, res) can set setting `geotoh3_argument_order = 'lon_lat'`. [#78852](https://github.com/ClickHouse/ClickHouse/pull/78852) ([Pratima Patel](https://github.com/pratimapatel2008)).
2222
* Add a filesystem cache setting `allow_dynamic_cache_resize`, by default `false`, to allow dynamic resize of filesystem cache. Why: in certain environments (ClickHouse Cloud) all the scaling events happen through the restart of the process and we would love this feature to be explicitly disabled to have more control over the behaviour + as a safety measure. This PR is marked as backward incompatible, because in older versions dynamic cache resize worked by default without special setting. [#79148](https://github.com/ClickHouse/ClickHouse/pull/79148) ([Kseniia Sumarokova](https://github.com/kssenii)).
2323
* Removed support for legacy index types `annoy` and `usearch`. Both have been stubs for a long time, i.e. every attempt to use the legacy indexes returned an error anyways. If you still have `annoy` and `usearch` indexes, please drop them. [#79802](https://github.com/ClickHouse/ClickHouse/pull/79802) ([Robert Schulze](https://github.com/rschu1ze)).
2424
* Remove `format_alter_commands_with_parentheses` server setting. The setting was introduced and disabled by default in 24.2. It was enabled by default in 25.2. As there are no LTS versions that don't support the new format, we can remove the setting. [#79970](https://github.com/ClickHouse/ClickHouse/pull/79970) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ geoToH3(lat, lon, resolution)
210210
- Hexagon index number. [UInt64](../../data-types/int-uint.md).
211211
- 0 in case of error. [UInt64](../../data-types/int-uint.md).
212212

213-
Note: In ClickHouse v25.4 or older, `geoToH3()` takes values in order `(lon, lat)`. As per ClickHouse v25.5, the input values are in order `(lat, lon)`. The previous behaviour can be restored using setting `geotoh3_lon_lat_input_order = true`.
213+
Note: In ClickHouse v25.4 or older, `geoToH3()` takes values in order `(lon, lat)`. As per ClickHouse v25.5, the input values are in order `(lat, lon)`. The previous behaviour can be restored using setting `geotoh3_argument_order = 'lon_lat'`.
214214

215215
**Example**
216216

src/Core/Settings.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,9 +3651,9 @@ If enabled, functions 'least' and 'greatest' return NULL if one of their argumen
36513651
DECLARE(Bool, h3togeo_lon_lat_result_order, false, R"(
36523652
Function 'h3ToGeo' returns (lon, lat) if true, otherwise (lat, lon).
36533653
)", 0) \
3654-
DECLARE(Bool, geotoh3_lon_lat_input_order, false, R"(
3655-
Function 'geoToH3' accepts (lon, lat) if true, otherwise (lat, lon).
3656-
)", 0) \
3654+
DECLARE(GeoToH3ArgumentOrder, geotoh3_argument_order, GeoToH3ArgumentOrder::LAT_LON, R"(
3655+
Function 'geoToH3' accepts (lon, lat) if set to 'lon_lat' and (lat, lon) if set to 'lat_lon'.
3656+
)", BETA) \
36573657
DECLARE(UInt64, max_partitions_per_insert_block, 100, R"(
36583658
Limits the maximum number of partitions in a single inserted block
36593659
and an exception is thrown if the block contains too many partitions.

src/Core/Settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class WriteBuffer;
104104
M(CLASS_NAME, UInt64) \
105105
M(CLASS_NAME, UInt64Auto) \
106106
M(CLASS_NAME, URI) \
107-
M(CLASS_NAME, VectorSearchFilterStrategy)
107+
M(CLASS_NAME, VectorSearchFilterStrategy) \
108+
M(CLASS_NAME, GeoToH3ArgumentOrder)
108109

109110

110111
COMMON_SETTINGS_SUPPORTED_TYPES(Settings, DECLARE_SETTING_TRAIT)

src/Core/SettingsChangesHistory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const VersionToSettingsChangesMap & getSettingsChangesHistory()
7575
addSettingsChanges(settings_changes_history, "25.5",
7676
{
7777
/// Release closed. Please use 25.6
78-
{"geotoh3_lon_lat_input_order", true, false, "A new setting for legacy behaviour to set lon and lat order"},
78+
{"geotoh3_argument_order", "lon_lat", "lat_lon", "A new setting for legacy behaviour to set lon and lat argument order"},
7979
{"secondary_indices_enable_bulk_filtering", false, true, "A new algorithm for filtering by data skipping indices"},
8080
{"implicit_table_at_top_level", "", "", "A new setting, used in clickhouse-local"},
8181
{"use_skip_indexes_if_final_exact_mode", 0, 0, "This setting was introduced to help FINAL query return correct results with skip indexes"},

src/Core/SettingsEnums.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,10 @@ IMPLEMENT_SETTING_ENUM(
312312
{"prefilter", VectorSearchFilterStrategy::PREFILTER},
313313
{"postfilter", VectorSearchFilterStrategy::POSTFILTER}})
314314

315+
IMPLEMENT_SETTING_ENUM(
316+
GeoToH3ArgumentOrder,
317+
ErrorCodes::BAD_ARGUMENTS,
318+
{{"lat_lon", GeoToH3ArgumentOrder::LAT_LON},
319+
{"lon_lat", GeoToH3ArgumentOrder::LON_LAT}})
320+
315321
}

src/Core/SettingsEnums.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,12 @@ enum class VectorSearchFilterStrategy : uint8_t
405405

406406
DECLARE_SETTING_ENUM(VectorSearchFilterStrategy)
407407

408+
enum class GeoToH3ArgumentOrder : uint8_t
409+
{
410+
LAT_LON,
411+
LON_LAT,
412+
};
413+
414+
DECLARE_SETTING_ENUM(GeoToH3ArgumentOrder)
415+
408416
}

src/Functions/geoToH3.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <Functions/IFunction.h>
1111
#include <Interpreters/Context.h>
1212
#include <Core/Settings.h>
13+
#include <Core/SettingsEnums.h>
1314
#include <base/range.h>
1415

1516
#include <constants.h>
@@ -20,7 +21,7 @@ namespace DB
2021
{
2122
namespace Setting
2223
{
23-
extern const SettingsBool geotoh3_lon_lat_input_order;
24+
extern const SettingsGeoToH3ArgumentOrder geotoh3_argument_order;
2425
}
2526
namespace ErrorCodes
2627
{
@@ -37,14 +38,14 @@ namespace
3738
/// and returns h3 index of this point
3839
class FunctionGeoToH3 : public IFunction
3940
{
40-
const bool geotoh3_lon_lat_input_order;
41+
GeoToH3ArgumentOrder geotoh3_argument_order;
4142
public:
4243
static constexpr auto name = "geoToH3";
4344

4445
static FunctionPtr create(ContextPtr context) { return std::make_shared<FunctionGeoToH3>(context); }
4546

4647
explicit FunctionGeoToH3(ContextPtr context)
47-
: geotoh3_lon_lat_input_order(context->getSettingsRef()[Setting::geotoh3_lon_lat_input_order])
48+
: geotoh3_argument_order(context->getSettingsRef()[Setting::geotoh3_argument_order])
4849
{
4950
}
5051

@@ -94,7 +95,7 @@ class FunctionGeoToH3 : public IFunction
9495
const ColumnFloat64 * col_lat = nullptr;
9596
const ColumnFloat64 * col_lon = nullptr;
9697

97-
if (geotoh3_lon_lat_input_order)
98+
if (geotoh3_argument_order == GeoToH3ArgumentOrder::LON_LAT)
9899
{
99100
col_lon = checkAndGetColumn<ColumnFloat64>(non_const_arguments[0].column.get());
100101
col_lat = checkAndGetColumn<ColumnFloat64>(non_const_arguments[1].column.get());
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Tags: no-fasttest
22
-- no-fasttest: h3ToGeo needs binary with Uber H3 libary
33

4-
-- Test for setting 'geotoh3_lon_lat_input_order'
4+
-- Test for setting 'geotoh3_argument_order'
55

6-
SELECT geoToH3(37.79506683, 55.71290588, 15) AS h3Index SETTINGS geotoh3_lon_lat_input_order = true;
7-
SELECT geoToH3(55.71290588, 37.79506683, 15) AS h3Index SETTINGS geotoh3_lon_lat_input_order = false;
6+
SELECT geoToH3(37.79506683, 55.71290588, 15) AS h3Index SETTINGS geotoh3_argument_order = 'lon_lat';
7+
SELECT geoToH3(55.71290588, 37.79506683, 15) AS h3Index SETTINGS geotoh3_argument_order = 'lat_lon';

0 commit comments

Comments
 (0)