From b0f799b7f5ae4991ceab177462c3be260ec52d2f Mon Sep 17 00:00:00 2001 From: Sreesh Maheshwar Date: Sun, 28 Jun 2026 00:21:23 +0100 Subject: [PATCH] refactor: mark PartitionField and SortField getters [[nodiscard]] These are pure accessors and predicates; discarding their result is a bug. Mirrors the existing [[nodiscard]] annotations on the analogous SchemaField getters in schema_field.h. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/iceberg/partition_field.h | 10 +++++----- src/iceberg/sort_field.h | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/iceberg/partition_field.h b/src/iceberg/partition_field.h index 5206cf260..e01fe7115 100644 --- a/src/iceberg/partition_field.h +++ b/src/iceberg/partition_field.h @@ -45,18 +45,18 @@ class ICEBERG_EXPORT PartitionField : public util::Formattable { std::shared_ptr transform); /// \brief Get the source field ID. - int32_t source_id() const; + [[nodiscard]] int32_t source_id() const; /// \brief Get the partition field ID. - int32_t field_id() const; + [[nodiscard]] int32_t field_id() const; /// \brief Get the partition field name. - std::string_view name() const; + [[nodiscard]] std::string_view name() const; /// \brief Get the transform type. - std::shared_ptr const& transform() const; + [[nodiscard]] std::shared_ptr const& transform() const; - std::string ToString() const override; + [[nodiscard]] std::string ToString() const override; friend bool operator==(const PartitionField& lhs, const PartitionField& rhs) { return lhs.Equals(rhs); diff --git a/src/iceberg/sort_field.h b/src/iceberg/sort_field.h index 223c573ba..c9f4cf9c0 100644 --- a/src/iceberg/sort_field.h +++ b/src/iceberg/sort_field.h @@ -96,21 +96,21 @@ class ICEBERG_EXPORT SortField : public util::Formattable { SortDirection direction, NullOrder null_order); /// \brief Get the source field ID. - int32_t source_id() const; + [[nodiscard]] int32_t source_id() const; /// \brief Get the transform type. - const std::shared_ptr& transform() const; + [[nodiscard]] const std::shared_ptr& transform() const; /// \brief Get the sort direction. - SortDirection direction() const; + [[nodiscard]] SortDirection direction() const; /// \brief Get the null order. - NullOrder null_order() const; + [[nodiscard]] NullOrder null_order() const; /// \brief Checks whether this field's order satisfies another field's order. - bool Satisfies(const SortField& other) const; + [[nodiscard]] bool Satisfies(const SortField& other) const; - std::string ToString() const override; + [[nodiscard]] std::string ToString() const override; friend bool operator==(const SortField& lhs, const SortField& rhs) { if (&lhs == &rhs) {