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{
2122namespace Setting
2223{
23- extern const SettingsString geotoh3_argument_order;
24+ extern const SettingsGeoToH3ArgumentOrder geotoh3_argument_order;
2425}
2526namespace ErrorCodes
2627{
@@ -37,7 +38,7 @@ namespace
3738// / and returns h3 index of this point
3839class FunctionGeoToH3 : public IFunction
3940{
40- const String geotoh3_argument_order;
41+ GeoToH3ArgumentOrder geotoh3_argument_order;
4142public:
4243 static constexpr auto name = " geoToH3" ;
4344
@@ -46,12 +47,6 @@ class FunctionGeoToH3 : public IFunction
4647 explicit FunctionGeoToH3 (ContextPtr context)
4748 : geotoh3_argument_order(context->getSettingsRef ()[Setting::geotoh3_argument_order])
4849 {
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);
5550 }
5651
5752 std::string getName () const override { return name; }
@@ -100,12 +95,12 @@ class FunctionGeoToH3 : public IFunction
10095 const ColumnFloat64 * col_lat = nullptr ;
10196 const ColumnFloat64 * col_lon = nullptr ;
10297
103- if (geotoh3_argument_order == " lon_lat " )
98+ if (geotoh3_argument_order == GeoToH3ArgumentOrder::LON_LAT )
10499 {
105100 col_lon = checkAndGetColumn<ColumnFloat64>(non_const_arguments[0 ].column .get ());
106101 col_lat = checkAndGetColumn<ColumnFloat64>(non_const_arguments[1 ].column .get ());
107102 }
108- else // "lat_lon" (setting value is validated in the constructor)
103+ else
109104 {
110105 col_lat = checkAndGetColumn<ColumnFloat64>(non_const_arguments[0 ].column .get ());
111106 col_lon = checkAndGetColumn<ColumnFloat64>(non_const_arguments[1 ].column .get ());
0 commit comments