Skip to content

Commit 4eea8c8

Browse files
committed
rename to geotoh3_argument_order and use enum values
1 parent c7fd31f commit 4eea8c8

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-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_argument_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_argument_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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,8 +3651,8 @@ 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_argument_order, false, R"(
3655-
Function 'geoToH3' accepts (lon, lat) if true, otherwise (lat, lon).
3654+
DECLARE(String, geotoh3_argument_order, "lat_lon", R"(
3655+
Function 'geoToH3' accepts (lon, lat) if set to 'lon_lat' and (lat, lon) if set to 'lat_lon'.
36563656
)", 0) \
36573657
DECLARE(UInt64, max_partitions_per_insert_block, 100, R"(
36583658
Limits the maximum number of partitions in a single inserted block

src/Core/SettingsChangesHistory.cpp

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

src/Functions/geoToH3.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace DB
2020
{
2121
namespace Setting
2222
{
23-
extern const SettingsBool geotoh3_lon_lat_argument_order;
23+
extern const SettingsString geotoh3_argument_order;
2424
}
2525
namespace ErrorCodes
2626
{
@@ -37,15 +37,21 @@ namespace
3737
/// and returns h3 index of this point
3838
class FunctionGeoToH3 : public IFunction
3939
{
40-
const bool geotoh3_lon_lat_argument_order;
40+
const String geotoh3_argument_order;
4141
public:
4242
static constexpr auto name = "geoToH3";
4343

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

4646
explicit FunctionGeoToH3(ContextPtr context)
47-
: geotoh3_lon_lat_argument_order(context->getSettingsRef()[Setting::geotoh3_lon_lat_argument_order])
47+
: geotoh3_argument_order(context->getSettingsRef()[Setting::geotoh3_argument_order])
4848
{
49+
// Validate that the setting value is either "lat_lon" or "lon_lat".
50+
if (geotoh3_argument_order != "lat_lon" || geotoh3_argument_order != "lon_lat")
51+
throw Exception(
52+
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
53+
"Invalid value for 'geotoh3_argument_order'. Must be 'lat_lon' or 'lon_lat'. Got: {}",
54+
geotoh3_argument_order);
4955
}
5056

5157
std::string getName() const override { return name; }
@@ -94,12 +100,12 @@ class FunctionGeoToH3 : public IFunction
94100
const ColumnFloat64 * col_lat = nullptr;
95101
const ColumnFloat64 * col_lon = nullptr;
96102

97-
if (geotoh3_lon_lat_argument_order)
103+
if (geotoh3_argument_order == "lon_lat")
98104
{
99105
col_lon = checkAndGetColumn<ColumnFloat64>(non_const_arguments[0].column.get());
100106
col_lat = checkAndGetColumn<ColumnFloat64>(non_const_arguments[1].column.get());
101107
}
102-
else
108+
else // "lat_lon" (setting value is validated in the constructor)
103109
{
104110
col_lat = checkAndGetColumn<ColumnFloat64>(non_const_arguments[0].column.get());
105111
col_lon = checkAndGetColumn<ColumnFloat64>(non_const_arguments[1].column.get());

tests/queries/0_stateless/00937_test_use_header_tsv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS tsv"
99
$CLICKHOUSE_CLIENT --query="CREATE TABLE tsv (d Date, u UInt8, str String) ENGINE = TinyLog"
1010

1111
INSERT_QUERY='$CLICKHOUSE_CLIENT --query="INSERT INTO tsv FORMAT TSVWithNames"'
12-
USE_HEADER='--input_format_with_names_use_header=1'
12+
USE_HEADER='--input_format_with_names_use_header=1 --output_format_parallel_formatting=1'
1313
SKIP_UNKNOWN='--input_format_skip_unknown_fields=1'
1414

1515
# Simple check for parsing
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_argument_order'
4+
-- Test for setting 'geotoh3_argument_order'
55

6-
SELECT geoToH3(37.79506683, 55.71290588, 15) AS h3Index SETTINGS geotoh3_lon_lat_argument_order = true;
7-
SELECT geoToH3(55.71290588, 37.79506683, 15) AS h3Index SETTINGS geotoh3_lon_lat_argument_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)