From 4316c85b11e858e89115e58921e3d223c126e7f8 Mon Sep 17 00:00:00 2001 From: liuxiaoyu Date: Fri, 6 Jun 2025 11:12:33 +0800 Subject: [PATCH 1/3] fix: fix build warning in switch case (#118) --- src/iceberg/json_internal.cc | 4 ++++ src/iceberg/schema_util.cc | 4 ++++ src/iceberg/transform.cc | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/src/iceberg/json_internal.cc b/src/iceberg/json_internal.cc index 3614ed230..b01d13450 100644 --- a/src/iceberg/json_internal.cc +++ b/src/iceberg/json_internal.cc @@ -43,6 +43,7 @@ #include "iceberg/util/formatter.h" // IWYU pragma: keep #include "iceberg/util/macros.h" #include "iceberg/util/timepoint.h" +#include "iceberg/util/unreachable.h" namespace iceberg { @@ -476,6 +477,9 @@ nlohmann::json ToJson(const Type& type) { } case TypeId::kUuid: return "uuid"; + default: + internal::Unreachable(std::format("Unknown type id: {}", + static_cast(type.type_id()))); } } diff --git a/src/iceberg/schema_util.cc b/src/iceberg/schema_util.cc index 3e409efd7..ea5dd5374 100644 --- a/src/iceberg/schema_util.cc +++ b/src/iceberg/schema_util.cc @@ -29,6 +29,7 @@ #include "iceberg/util/checked_cast.h" #include "iceberg/util/formatter_internal.h" #include "iceberg/util/macros.h" +#include "iceberg/util/unreachable.h" namespace iceberg { @@ -171,6 +172,9 @@ std::string_view ToString(FieldProjection::Kind kind) { return "default"; case FieldProjection::Kind::kNull: return "null"; + default: + internal::Unreachable(std::format("Unknown field projection kind: {}", + static_cast(kind))); } } diff --git a/src/iceberg/transform.cc b/src/iceberg/transform.cc index dc0529766..3a1bec86b 100644 --- a/src/iceberg/transform.cc +++ b/src/iceberg/transform.cc @@ -24,6 +24,7 @@ #include "iceberg/transform_function.h" #include "iceberg/type.h" +#include "iceberg/util/unreachable.h" namespace iceberg { namespace { @@ -58,6 +59,9 @@ constexpr std::string_view TransformTypeToString(TransformType type) { return kHourName; case TransformType::kVoid: return kVoidName; + default: + internal::Unreachable(std::format("Unknown transform type: {}", + static_cast(type))); } } @@ -165,6 +169,9 @@ std::string Transform::ToString() const { case TransformType::kTruncate: return std::format("{}[{}]", TransformTypeToString(transform_type_), std::get(param_)); + default: + internal::Unreachable(std::format("Unknown transform type: {}", + static_cast(transform_type_))); } } From e41463c5c7f33557157542d0850b7127fee21e46 Mon Sep 17 00:00:00 2001 From: liuxiaoyu Date: Fri, 6 Jun 2025 11:56:29 +0800 Subject: [PATCH 2/3] put Unreachable outside --- src/iceberg/json_internal.cc | 5 ++--- src/iceberg/schema_util.cc | 5 ++--- src/iceberg/transform.cc | 10 ++++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/iceberg/json_internal.cc b/src/iceberg/json_internal.cc index b01d13450..e3e66116e 100644 --- a/src/iceberg/json_internal.cc +++ b/src/iceberg/json_internal.cc @@ -477,10 +477,9 @@ nlohmann::json ToJson(const Type& type) { } case TypeId::kUuid: return "uuid"; - default: - internal::Unreachable(std::format("Unknown type id: {}", - static_cast(type.type_id()))); } + internal::Unreachable( + std::format("Unknown type id: {}", static_cast(type.type_id()))); } nlohmann::json ToJson(const Schema& schema) { diff --git a/src/iceberg/schema_util.cc b/src/iceberg/schema_util.cc index ea5dd5374..4139a2b38 100644 --- a/src/iceberg/schema_util.cc +++ b/src/iceberg/schema_util.cc @@ -172,10 +172,9 @@ std::string_view ToString(FieldProjection::Kind kind) { return "default"; case FieldProjection::Kind::kNull: return "null"; - default: - internal::Unreachable(std::format("Unknown field projection kind: {}", - static_cast(kind))); } + internal::Unreachable( + std::format("Unknown field projection kind: {}", static_cast(kind))); } std::string ToString(const FieldProjection& projection) { diff --git a/src/iceberg/transform.cc b/src/iceberg/transform.cc index 3a1bec86b..9a9b6e1f7 100644 --- a/src/iceberg/transform.cc +++ b/src/iceberg/transform.cc @@ -59,10 +59,9 @@ constexpr std::string_view TransformTypeToString(TransformType type) { return kHourName; case TransformType::kVoid: return kVoidName; - default: - internal::Unreachable(std::format("Unknown transform type: {}", - static_cast(type))); } + internal::Unreachable( + std::format("Unknown transform type: {}", static_cast(type))); } std::shared_ptr Transform::Identity() { @@ -169,10 +168,9 @@ std::string Transform::ToString() const { case TransformType::kTruncate: return std::format("{}[{}]", TransformTypeToString(transform_type_), std::get(param_)); - default: - internal::Unreachable(std::format("Unknown transform type: {}", - static_cast(transform_type_))); } + internal::Unreachable( + std::format("Unknown transform type: {}", static_cast(transform_type_))); } TransformFunction::TransformFunction(TransformType transform_type, From d17a34782bb629e12824c38c3aaa54c86fc02ceb Mon Sep 17 00:00:00 2001 From: liuxiaoyu Date: Fri, 6 Jun 2025 12:03:39 +0800 Subject: [PATCH 3/3] format code --- src/iceberg/transform.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iceberg/transform.cc b/src/iceberg/transform.cc index 9a9b6e1f7..95f6fe717 100644 --- a/src/iceberg/transform.cc +++ b/src/iceberg/transform.cc @@ -61,7 +61,7 @@ constexpr std::string_view TransformTypeToString(TransformType type) { return kVoidName; } internal::Unreachable( - std::format("Unknown transform type: {}", static_cast(type))); + std::format("Unknown transform type: {}", static_cast(type))); } std::shared_ptr Transform::Identity() {