Skip to content

Commit c906ae3

Browse files
committed
fix to use enum type
1 parent 4eea8c8 commit c906ae3

File tree

6 files changed

+24
-14
lines changed

6 files changed

+24
-14
lines changed

src/Core/Settings.cpp

Lines changed: 2 additions & 2 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(String, geotoh3_argument_order, "lat_lon", R"(
3654+
DECLARE(GeoToH3ArgumentOrder, geotoh3_argument_order, GeoToH3ArgumentOrder::LAT_LON, R"(
36553655
Function 'geoToH3' accepts (lon, lat) if set to 'lon_lat' and (lat, lon) if set to 'lat_lon'.
3656-
)", 0) \
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/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 & 10 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 SettingsString geotoh3_argument_order;
24+
extern const SettingsGeoToH3ArgumentOrder geotoh3_argument_order;
2425
}
2526
namespace ErrorCodes
2627
{
@@ -37,7 +38,7 @@ namespace
3738
/// and returns h3 index of this point
3839
class FunctionGeoToH3 : public IFunction
3940
{
40-
const String geotoh3_argument_order;
41+
GeoToH3ArgumentOrder geotoh3_argument_order;
4142
public:
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());

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 --output_format_parallel_formatting=1'
12+
USE_HEADER='--input_format_with_names_use_header=1'
1313
SKIP_UNKNOWN='--input_format_skip_unknown_fields=1'
1414

1515
# Simple check for parsing

0 commit comments

Comments
 (0)