From 4c2c003bbb275a8d5ceb3078a2748e892e617312 Mon Sep 17 00:00:00 2001 From: Jinchul Kim Date: Wed, 19 Nov 2025 21:48:49 +0000 Subject: [PATCH] refactor: suppress warnings --- .../catalog/memory/in_memory_catalog.cc | 30 ++++--- src/iceberg/catalog/rest/types.h | 60 +++++++------- src/iceberg/expression/binder.cc | 6 +- src/iceberg/expression/expression.h | 2 +- src/iceberg/expression/expressions.cc | 3 +- src/iceberg/expression/literal.cc | 2 +- src/iceberg/file_io.h | 9 ++- src/iceberg/file_reader.h | 14 ++-- src/iceberg/manifest_adapter.cc | 7 +- src/iceberg/manifest_reader_internal.cc | 7 +- src/iceberg/name_mapping.cc | 2 +- src/iceberg/name_mapping.h | 6 +- src/iceberg/schema.cc | 11 +-- src/iceberg/schema.h | 1 + src/iceberg/snapshot.h | 14 ++-- src/iceberg/table_metadata.cc | 73 ++++++++++------- src/iceberg/table_metadata.h | 42 +++++----- src/iceberg/table_requirements.cc | 10 +-- src/iceberg/table_update.cc | 81 +++++++++++-------- src/iceberg/test/schema_test.cc | 24 +++--- src/iceberg/test/schema_util_test.cc | 4 +- src/iceberg/test/transform_test.cc | 2 +- src/iceberg/util/conversions.cc | 2 +- src/iceberg/util/truncate_util.cc | 2 +- 24 files changed, 227 insertions(+), 187 deletions(-) diff --git a/src/iceberg/catalog/memory/in_memory_catalog.cc b/src/iceberg/catalog/memory/in_memory_catalog.cc index 753c3358a..ea0ae908b 100644 --- a/src/iceberg/catalog/memory/in_memory_catalog.cc +++ b/src/iceberg/catalog/memory/in_memory_catalog.cc @@ -384,23 +384,25 @@ Result> InMemoryCatalog::ListTables( } Result> InMemoryCatalog::CreateTable( - const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec, - const std::string& location, - const std::unordered_map& properties) { + [[maybe_unused]] const TableIdentifier& identifier, + [[maybe_unused]] const Schema& schema, [[maybe_unused]] const PartitionSpec& spec, + [[maybe_unused]] const std::string& location, + [[maybe_unused]] const std::unordered_map& properties) { return NotImplemented("create table"); } Result> InMemoryCatalog::UpdateTable( - const TableIdentifier& identifier, - const std::vector>& requirements, - const std::vector>& updates) { + [[maybe_unused]] const TableIdentifier& identifier, + [[maybe_unused]] const std::vector>& requirements, + [[maybe_unused]] const std::vector>& updates) { return NotImplemented("update table"); } Result> InMemoryCatalog::StageCreateTable( - const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec, - const std::string& location, - const std::unordered_map& properties) { + [[maybe_unused]] const TableIdentifier& identifier, + [[maybe_unused]] const Schema& schema, [[maybe_unused]] const PartitionSpec& spec, + [[maybe_unused]] const std::string& location, + [[maybe_unused]] const std::unordered_map& properties) { return NotImplemented("stage create table"); } @@ -409,14 +411,15 @@ Result InMemoryCatalog::TableExists(const TableIdentifier& identifier) con return root_namespace_->TableExists(identifier); } -Status InMemoryCatalog::DropTable(const TableIdentifier& identifier, bool purge) { +Status InMemoryCatalog::DropTable(const TableIdentifier& identifier, + [[maybe_unused]] bool purge) { std::unique_lock lock(mutex_); // TODO(Guotao): Delete all metadata files if purge is true. return root_namespace_->UnregisterTable(identifier); } -Status InMemoryCatalog::RenameTable(const TableIdentifier& from, - const TableIdentifier& to) { +Status InMemoryCatalog::RenameTable([[maybe_unused]] const TableIdentifier& from, + [[maybe_unused]] const TableIdentifier& to) { std::unique_lock lock(mutex_); return NotImplemented("rename table"); } @@ -455,7 +458,8 @@ Result> InMemoryCatalog::RegisterTable( } std::unique_ptr InMemoryCatalog::BuildTable( - const TableIdentifier& identifier, const Schema& schema) const { + [[maybe_unused]] const TableIdentifier& identifier, + [[maybe_unused]] const Schema& schema) const { throw IcebergError("not implemented"); } diff --git a/src/iceberg/catalog/rest/types.h b/src/iceberg/catalog/rest/types.h index 2e32f967f..d07d16a56 100644 --- a/src/iceberg/catalog/rest/types.h +++ b/src/iceberg/catalog/rest/types.h @@ -39,9 +39,9 @@ namespace iceberg::rest { /// \brief Server-provided configuration for the catalog. struct ICEBERG_REST_EXPORT CatalogConfig { - std::unordered_map defaults; // required - std::unordered_map overrides; // required - std::vector endpoints; + std::unordered_map defaults{}; // required + std::unordered_map overrides{}; // required + std::vector endpoints{}; /// \brief Validates the CatalogConfig. Status Validate() const { @@ -55,10 +55,10 @@ struct ICEBERG_REST_EXPORT CatalogConfig { /// \brief JSON error payload returned in a response with further details on the error. struct ICEBERG_REST_EXPORT ErrorModel { - std::string message; // required - std::string type; // required - uint32_t code; // required - std::vector stack; + std::string message{}; // required + std::string type{}; // required + uint32_t code{}; // required + std::vector stack{}; /// \brief Validates the ErrorModel. Status Validate() const { @@ -77,7 +77,7 @@ struct ICEBERG_REST_EXPORT ErrorModel { /// \brief Error response body returned in a response. struct ICEBERG_REST_EXPORT ErrorResponse { - ErrorModel error; // required + ErrorModel error{}; // required /// \brief Validates the ErrorResponse. // We don't validate the error field because ErrorModel::Validate has been called in the @@ -87,8 +87,8 @@ struct ICEBERG_REST_EXPORT ErrorResponse { /// \brief Request to create a namespace. struct ICEBERG_REST_EXPORT CreateNamespaceRequest { - Namespace namespace_; // required - std::unordered_map properties; + Namespace namespace_{}; // required + std::unordered_map properties{}; /// \brief Validates the CreateNamespaceRequest. Status Validate() const { return {}; } @@ -96,8 +96,8 @@ struct ICEBERG_REST_EXPORT CreateNamespaceRequest { /// \brief Update or delete namespace properties request. struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesRequest { - std::vector removals; - std::unordered_map updates; + std::vector removals{}; + std::unordered_map updates{}; /// \brief Validates the UpdateNamespacePropertiesRequest. Status Validate() const { @@ -112,8 +112,8 @@ struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesRequest { /// \brief Request to register a table. struct ICEBERG_REST_EXPORT RegisterTableRequest { - std::string name; // required - std::string metadata_location; // required + std::string name{}; // required + std::string metadata_location{}; // required bool overwrite = false; /// \brief Validates the RegisterTableRequest. @@ -132,8 +132,8 @@ struct ICEBERG_REST_EXPORT RegisterTableRequest { /// \brief Request to rename a table. struct ICEBERG_REST_EXPORT RenameTableRequest { - TableIdentifier source; // required - TableIdentifier destination; // required + TableIdentifier source{}; // required + TableIdentifier destination{}; // required /// \brief Validates the RenameTableRequest. Status Validate() const { @@ -148,9 +148,9 @@ using PageToken = std::string; /// \brief Result body for table create/load/register APIs. struct ICEBERG_REST_EXPORT LoadTableResult { - std::string metadata_location; - std::shared_ptr metadata; // required - std::unordered_map config; + std::string metadata_location{}; + std::shared_ptr metadata{}; // required + std::unordered_map config{}; // TODO(Li Feiyang): Add std::shared_ptr storage_credential; /// \brief Validates the LoadTableResult. @@ -170,8 +170,8 @@ using LoadTableResponse = LoadTableResult; /// \brief Response body for listing namespaces. struct ICEBERG_REST_EXPORT ListNamespacesResponse { - PageToken next_page_token; - std::vector namespaces; + PageToken next_page_token{}; + std::vector namespaces{}; /// \brief Validates the ListNamespacesResponse. Status Validate() const { return {}; } @@ -179,8 +179,8 @@ struct ICEBERG_REST_EXPORT ListNamespacesResponse { /// \brief Response body after creating a namespace. struct ICEBERG_REST_EXPORT CreateNamespaceResponse { - Namespace namespace_; // required - std::unordered_map properties; + Namespace namespace_{}; // required + std::unordered_map properties{}; /// \brief Validates the CreateNamespaceResponse. Status Validate() const { return {}; } @@ -188,8 +188,8 @@ struct ICEBERG_REST_EXPORT CreateNamespaceResponse { /// \brief Response body for loading namespace properties. struct ICEBERG_REST_EXPORT GetNamespaceResponse { - Namespace namespace_; // required - std::unordered_map properties; + Namespace namespace_{}; // required + std::unordered_map properties{}; /// \brief Validates the GetNamespaceResponse. Status Validate() const { return {}; } @@ -197,9 +197,9 @@ struct ICEBERG_REST_EXPORT GetNamespaceResponse { /// \brief Response body after updating namespace properties. struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesResponse { - std::vector updated; // required - std::vector removed; // required - std::vector missing; + std::vector updated{}; // required + std::vector removed{}; // required + std::vector missing{}; /// \brief Validates the UpdateNamespacePropertiesResponse. Status Validate() const { return {}; } @@ -207,8 +207,8 @@ struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesResponse { /// \brief Response body for listing tables in a namespace. struct ICEBERG_REST_EXPORT ListTablesResponse { - PageToken next_page_token; - std::vector identifiers; + PageToken next_page_token{}; + std::vector identifiers{}; /// \brief Validates the ListTablesResponse. Status Validate() const { return {}; } diff --git a/src/iceberg/expression/binder.cc b/src/iceberg/expression/binder.cc index 62c735308..aee4e83cc 100644 --- a/src/iceberg/expression/binder.cc +++ b/src/iceberg/expression/binder.cc @@ -84,11 +84,13 @@ Result IsBoundVisitor::Or(bool left_result, bool right_result) { return left_result && right_result; } -Result IsBoundVisitor::Predicate(const std::shared_ptr& pred) { +Result IsBoundVisitor::Predicate( + [[maybe_unused]] const std::shared_ptr& pred) { return true; } -Result IsBoundVisitor::Predicate(const std::shared_ptr& pred) { +Result IsBoundVisitor::Predicate( + [[maybe_unused]] const std::shared_ptr& pred) { return false; } diff --git a/src/iceberg/expression/expression.h b/src/iceberg/expression/expression.h index e6e19ea83..b15f77143 100644 --- a/src/iceberg/expression/expression.h +++ b/src/iceberg/expression/expression.h @@ -75,7 +75,7 @@ class ICEBERG_EXPORT Expression : public util::Formattable { /// \brief Returns whether this expression will accept the same values as another. /// \param other another expression /// \return true if the expressions are equivalent - virtual bool Equals(const Expression& other) const { + virtual bool Equals([[maybe_unused]] const Expression& other) const { // only bound predicates can be equivalent return false; } diff --git a/src/iceberg/expression/expressions.cc b/src/iceberg/expression/expressions.cc index b3e88ff18..26957f3f3 100644 --- a/src/iceberg/expression/expressions.cc +++ b/src/iceberg/expression/expressions.cc @@ -372,7 +372,8 @@ std::shared_ptr Expressions::Ref(std::string name) { return ref; } -Literal Expressions::Lit(Literal::Value value, std::shared_ptr type) { +Literal Expressions::Lit([[maybe_unused]] Literal::Value value, + [[maybe_unused]] std::shared_ptr type) { throw ExpressionError("Literal creation is not implemented"); } diff --git a/src/iceberg/expression/literal.cc b/src/iceberg/expression/literal.cc index 4f4a3c31b..34e907275 100644 --- a/src/iceberg/expression/literal.cc +++ b/src/iceberg/expression/literal.cc @@ -245,7 +245,7 @@ Result LiteralCaster::CastFromBinary( switch (target_type->type_id()) { case TypeId::kFixed: { auto target_fixed_type = internal::checked_pointer_cast(target_type); - if (binary_val.size() == target_fixed_type->length()) { + if (static_cast(binary_val.size()) == target_fixed_type->length()) { return Literal::Fixed(std::move(binary_val)); } return InvalidArgument("Failed to cast Binary with length {} to Fixed({})", diff --git a/src/iceberg/file_io.h b/src/iceberg/file_io.h index 259da7556..ad5b44ad0 100644 --- a/src/iceberg/file_io.h +++ b/src/iceberg/file_io.h @@ -49,8 +49,8 @@ class ICEBERG_EXPORT FileIO { /// the length to read, e.g. S3 `GetObject` has a Range parameter. /// \return The content of the file if the read succeeded, an error code if the read /// failed. - virtual Result ReadFile(const std::string& file_location, - std::optional length) { + virtual Result ReadFile([[maybe_unused]] const std::string& file_location, + [[maybe_unused]] std::optional length) { // We provide a default implementation to avoid Windows linker error LNK2019. return NotImplemented("ReadFile not implemented"); } @@ -62,7 +62,8 @@ class ICEBERG_EXPORT FileIO { /// \param overwrite If true, overwrite the file if it exists. If false, fail if the /// file exists. /// \return void if the write succeeded, an error code if the write failed. - virtual Status WriteFile(const std::string& file_location, std::string_view content) { + virtual Status WriteFile([[maybe_unused]] const std::string& file_location, + [[maybe_unused]] std::string_view content) { return NotImplemented("WriteFile not implemented"); } @@ -70,7 +71,7 @@ class ICEBERG_EXPORT FileIO { /// /// \param file_location The location of the file to delete. /// \return void if the delete succeeded, an error code if the delete failed. - virtual Status DeleteFile(const std::string& file_location) { + virtual Status DeleteFile([[maybe_unused]] const std::string& file_location) { return NotImplemented("DeleteFile not implemented"); } }; diff --git a/src/iceberg/file_reader.h b/src/iceberg/file_reader.h index d7e3b092d..fba384dcf 100644 --- a/src/iceberg/file_reader.h +++ b/src/iceberg/file_reader.h @@ -87,23 +87,23 @@ class ReaderProperties : public ConfigBase { /// \brief Options for creating a reader. struct ICEBERG_EXPORT ReaderOptions { /// \brief The path to the file to read. - std::string path; + std::string path{}; /// \brief The total length of the file. - std::optional length; + std::optional length{}; /// \brief The split to read. - std::optional split; + std::optional split{}; /// \brief FileIO instance to open the file. Reader implementations should down cast it /// to the specific FileIO implementation. By default, the `iceberg-bundle` library uses /// `ArrowFileSystemFileIO` as the default implementation. - std::shared_ptr io; + std::shared_ptr io{}; /// \brief The projection schema to read from the file. This field is required. - std::shared_ptr projection; + std::shared_ptr projection{}; /// \brief The filter to apply to the data. Reader implementations may ignore this if /// the file format does not support filtering. - std::shared_ptr filter; + std::shared_ptr filter{}; /// \brief Name mapping for schema evolution compatibility. Used when reading files /// that may have different field names than the current schema. - std::shared_ptr name_mapping; + std::shared_ptr name_mapping{}; /// \brief Format-specific or implementation-specific properties. std::shared_ptr properties = ReaderProperties::default_properties(); }; diff --git a/src/iceberg/manifest_adapter.cc b/src/iceberg/manifest_adapter.cc index 76ed0eca9..14a61f189 100644 --- a/src/iceberg/manifest_adapter.cc +++ b/src/iceberg/manifest_adapter.cc @@ -164,13 +164,14 @@ ManifestEntryAdapter::~ManifestEntryAdapter() { Status ManifestEntryAdapter::AppendPartitionValues( ArrowArray* array, const std::shared_ptr& partition_type, const std::vector& partition_values) { - if (array->n_children != partition_type->fields().size()) [[unlikely]] { + auto fields = partition_type->fields(); + auto num_fields = static_cast(fields.size()); + if (array->n_children != num_fields) [[unlikely]] { return InvalidArrowData("Arrow array of partition does not match partition type."); } - if (partition_values.size() != partition_type->fields().size()) [[unlikely]] { + if (partition_values.size() != fields.size()) [[unlikely]] { return InvalidArrowData("Literal list of partition does not match partition type."); } - auto fields = partition_type->fields(); for (size_t i = 0; i < fields.size(); i++) { const auto& partition_value = partition_values[i]; diff --git a/src/iceberg/manifest_reader_internal.cc b/src/iceberg/manifest_reader_internal.cc index 346f19a8e..12fd54ffa 100644 --- a/src/iceberg/manifest_reader_internal.cc +++ b/src/iceberg/manifest_reader_internal.cc @@ -196,7 +196,7 @@ Result> ParseManifestList(ArrowSchema* schema, return InvalidManifestList("Columns size not match between schema:{} and array:{}", schema->n_children, array_in->n_children); } - if (iceberg_schema.fields().size() != array_in->n_children) { + if (static_cast(iceberg_schema.fields().size()) != array_in->n_children) { return InvalidManifestList("Columns size not match between schema:{} and array:{}", iceberg_schema.fields().size(), array_in->n_children); } @@ -333,7 +333,8 @@ Status ParseDataFile(const std::shared_ptr& data_file_schema, if (view_of_column->storage_type != ArrowType::NANOARROW_TYPE_STRUCT) { return InvalidManifest("DataFile field should be a struct."); } - if (view_of_column->n_children != data_file_schema->fields().size()) { + if (view_of_column->n_children != + static_cast(data_file_schema->fields().size())) { return InvalidManifest("DataFile schema size:{} not match with ArrayArray columns:{}", data_file_schema->fields().size(), view_of_column->n_children); } @@ -459,7 +460,7 @@ Result> ParseManifestEntry(ArrowSchema* schema, return InvalidManifest("Columns size not match between schema:{} and array:{}", schema->n_children, array_in->n_children); } - if (iceberg_schema.fields().size() != array_in->n_children) { + if (static_cast(iceberg_schema.fields().size()) != array_in->n_children) { return InvalidManifest("Columns size not match between schema:{} and array:{}", iceberg_schema.fields().size(), array_in->n_children); } diff --git a/src/iceberg/name_mapping.cc b/src/iceberg/name_mapping.cc index eaf6199ee..b8b548356 100644 --- a/src/iceberg/name_mapping.cc +++ b/src/iceberg/name_mapping.cc @@ -303,7 +303,7 @@ class CreateMappingVisitor { } template - Result> Visit(const T& type) const { + Result> Visit([[maybe_unused]] const T& type) const { return nullptr; } diff --git a/src/iceberg/name_mapping.h b/src/iceberg/name_mapping.h index 41ff2d14e..2e526a8ee 100644 --- a/src/iceberg/name_mapping.h +++ b/src/iceberg/name_mapping.h @@ -39,12 +39,12 @@ namespace iceberg { /// This class is trivial enough that we don't need any function. struct ICEBERG_EXPORT MappedField { /// \brief A required list of 0 or more names for a field. - std::unordered_set names; + std::unordered_set names{}; /// \brief An optional Iceberg field ID used when a field's name is present in `names`. - std::optional field_id; + std::optional field_id{}; /// \brief An optional list of field mappings for child field of structs, maps, and /// lists. - std::shared_ptr nested_mapping; + std::shared_ptr nested_mapping{}; friend bool operator==(const MappedField& lhs, const MappedField& rhs); }; diff --git a/src/iceberg/schema.cc b/src/iceberg/schema.cc index 8719f22b5..51c7678a9 100644 --- a/src/iceberg/schema.cc +++ b/src/iceberg/schema.cc @@ -100,8 +100,8 @@ class PositionPathVisitor { } // Non-struct types are not supported yet, but it is not an error. - Status Visit(const ListType& type) { return {}; } - Status Visit(const MapType& type) { return {}; } + Status Visit([[maybe_unused]] const ListType& type) { return {}; } + Status Visit([[maybe_unused]] const MapType& type) { return {}; } std::unordered_map> Finish() { return std::move(position_path_); @@ -214,7 +214,7 @@ IdToFieldVisitor::IdToFieldVisitor( std::unordered_map>& id_to_field) : id_to_field_(id_to_field) {} -Status IdToFieldVisitor::Visit(const PrimitiveType& type) { return {}; } +Status IdToFieldVisitor::Visit([[maybe_unused]] const PrimitiveType& type) { return {}; } Status IdToFieldVisitor::Visit(const NestedType& type) { const auto& nested = internal::checked_cast(type); @@ -300,8 +300,9 @@ Status NameToIdVisitor::Visit(const StructType& type, const std::string& path, return {}; } -Status NameToIdVisitor::Visit(const PrimitiveType& type, const std::string& path, - const std::string& short_path) { +Status NameToIdVisitor::Visit([[maybe_unused]] const PrimitiveType& type, + [[maybe_unused]] const std::string& path, + [[maybe_unused]] const std::string& short_path) { return {}; } diff --git a/src/iceberg/schema.h b/src/iceberg/schema.h index 94a8764dc..f841c8d79 100644 --- a/src/iceberg/schema.h +++ b/src/iceberg/schema.h @@ -103,6 +103,7 @@ class ICEBERG_EXPORT Schema : public StructType { friend bool operator==(const Schema& lhs, const Schema& rhs) { return lhs.Equals(rhs); } private: + using Type::Equals; /// \brief Compare two schemas for equality. bool Equals(const Schema& other) const; diff --git a/src/iceberg/snapshot.h b/src/iceberg/snapshot.h index d41795d53..b80619e53 100644 --- a/src/iceberg/snapshot.h +++ b/src/iceberg/snapshot.h @@ -225,21 +225,21 @@ struct ICEBERG_EXPORT Snapshot { static constexpr int64_t kInvalidSnapshotId = -1; /// A unique long ID. - int64_t snapshot_id; + int64_t snapshot_id{}; /// The snapshot ID of the snapshot's parent. Omitted for any snapshot with no parent. - std::optional parent_snapshot_id; + std::optional parent_snapshot_id{}; /// A monotonically increasing long that tracks the order of changes to a table. - int64_t sequence_number; + int64_t sequence_number{}; /// A timestamp when the snapshot was created, used for garbage collection and table /// inspection. - TimePointMs timestamp_ms; + TimePointMs timestamp_ms{}; /// The location of a manifest list for this snapshot that tracks manifest files with /// additional metadata. - std::string manifest_list; + std::string manifest_list{}; /// A string map that summaries the snapshot changes, including operation. - std::unordered_map summary; + std::unordered_map summary{}; /// ID of the table's current schema when the snapshot was created. - std::optional schema_id; + std::optional schema_id{}; /// \brief Return the name of the DataOperations data operation that produced this /// snapshot. diff --git a/src/iceberg/table_metadata.cc b/src/iceberg/table_metadata.cc index 669e5a15b..753c0dac8 100644 --- a/src/iceberg/table_metadata.cc +++ b/src/iceberg/table_metadata.cc @@ -267,12 +267,12 @@ std::unique_ptr TableMetadataBuilder::BuildFrom( } TableMetadataBuilder& TableMetadataBuilder::SetMetadataLocation( - std::string_view metadata_location) { + [[maybe_unused]] std::string_view metadata_location) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::SetPreviousMetadataLocation( - std::string_view previous_metadata_location) { + [[maybe_unused]] std::string_view previous_metadata_location) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } @@ -309,87 +309,94 @@ TableMetadataBuilder& TableMetadataBuilder::AssignUUID(std::string_view uuid) { } TableMetadataBuilder& TableMetadataBuilder::UpgradeFormatVersion( - int8_t new_format_version) { + [[maybe_unused]] int8_t new_format_version) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::SetCurrentSchema( - std::shared_ptr schema, int32_t new_last_column_id) { + [[maybe_unused]] std::shared_ptr schema, + [[maybe_unused]] int32_t new_last_column_id) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::SetCurrentSchema(int32_t schema_id) { +TableMetadataBuilder& TableMetadataBuilder::SetCurrentSchema( + [[maybe_unused]] int32_t schema_id) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::AddSchema(std::shared_ptr schema) { +TableMetadataBuilder& TableMetadataBuilder::AddSchema( + [[maybe_unused]] std::shared_ptr schema) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::SetDefaultPartitionSpec( - std::shared_ptr spec) { + [[maybe_unused]] std::shared_ptr spec) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::SetDefaultPartitionSpec(int32_t spec_id) { +TableMetadataBuilder& TableMetadataBuilder::SetDefaultPartitionSpec( + [[maybe_unused]] int32_t spec_id) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::AddPartitionSpec( - std::shared_ptr spec) { + [[maybe_unused]] std::shared_ptr spec) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::RemovePartitionSpecs( - const std::vector& spec_ids) { + [[maybe_unused]] const std::vector& spec_ids) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::RemoveSchemas( - const std::vector& schema_ids) { + [[maybe_unused]] const std::vector& schema_ids) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::SetDefaultSortOrder( - std::shared_ptr order) { + [[maybe_unused]] std::shared_ptr order) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::SetDefaultSortOrder(int32_t order_id) { +TableMetadataBuilder& TableMetadataBuilder::SetDefaultSortOrder( + [[maybe_unused]] int32_t order_id) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::AddSortOrder( - std::shared_ptr order) { + [[maybe_unused]] std::shared_ptr order) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::AddSnapshot( - std::shared_ptr snapshot) { + [[maybe_unused]] std::shared_ptr snapshot) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::SetBranchSnapshot(int64_t snapshot_id, - const std::string& branch) { +TableMetadataBuilder& TableMetadataBuilder::SetBranchSnapshot( + [[maybe_unused]] int64_t snapshot_id, [[maybe_unused]] const std::string& branch) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::SetRef(const std::string& name, - std::shared_ptr ref) { +TableMetadataBuilder& TableMetadataBuilder::SetRef( + [[maybe_unused]] const std::string& name, + [[maybe_unused]] std::shared_ptr ref) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::RemoveRef(const std::string& name) { +TableMetadataBuilder& TableMetadataBuilder::RemoveRef( + [[maybe_unused]] const std::string& name) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::RemoveSnapshots( - const std::vector>& snapshots_to_remove) { + [[maybe_unused]] const std::vector>& snapshots_to_remove) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::RemoveSnapshots( - const std::vector& snapshot_ids) { + [[maybe_unused]] const std::vector& snapshot_ids) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } @@ -398,44 +405,48 @@ TableMetadataBuilder& TableMetadataBuilder::suppressHistoricalSnapshots() { } TableMetadataBuilder& TableMetadataBuilder::SetStatistics( - const std::shared_ptr& statistics_file) { + [[maybe_unused]] const std::shared_ptr& statistics_file) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::RemoveStatistics(int64_t snapshot_id) { +TableMetadataBuilder& TableMetadataBuilder::RemoveStatistics( + [[maybe_unused]] int64_t snapshot_id) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::SetPartitionStatistics( - const std::shared_ptr& partition_statistics_file) { + [[maybe_unused]] const std::shared_ptr& + partition_statistics_file) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::RemovePartitionStatistics( - int64_t snapshot_id) { + [[maybe_unused]] int64_t snapshot_id) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::SetProperties( - const std::unordered_map& updated) { + [[maybe_unused]] const std::unordered_map& updated) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::RemoveProperties( - const std::vector& removed) { + [[maybe_unused]] const std::vector& removed) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::SetLocation(std::string_view location) { +TableMetadataBuilder& TableMetadataBuilder::SetLocation( + [[maybe_unused]] std::string_view location) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } TableMetadataBuilder& TableMetadataBuilder::AddEncryptionKey( - std::shared_ptr key) { + [[maybe_unused]] std::shared_ptr key) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::RemoveEncryptionKey(std::string_view key_id) { +TableMetadataBuilder& TableMetadataBuilder::RemoveEncryptionKey( + [[maybe_unused]] std::string_view key_id) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } diff --git a/src/iceberg/table_metadata.h b/src/iceberg/table_metadata.h index 2a998c7a1..a44456f22 100644 --- a/src/iceberg/table_metadata.h +++ b/src/iceberg/table_metadata.h @@ -75,49 +75,49 @@ struct ICEBERG_EXPORT TableMetadata { static constexpr int64_t kInitialRowId = 0; /// An integer version number for the format - int8_t format_version; + int8_t format_version{}; /// A UUID that identifies the table - std::string table_uuid; + std::string table_uuid{}; /// The table's base location - std::string location; + std::string location{}; /// The table's highest assigned sequence number - int64_t last_sequence_number; + int64_t last_sequence_number{}; /// Timestamp in milliseconds from the unix epoch when the table was last updated. - TimePointMs last_updated_ms; + TimePointMs last_updated_ms{}; /// The highest assigned column ID for the table - int32_t last_column_id; + int32_t last_column_id{}; /// A list of schemas - std::vector> schemas; + std::vector> schemas{}; /// ID of the table's current schema - std::optional current_schema_id; + std::optional current_schema_id{}; /// A list of partition specs - std::vector> partition_specs; + std::vector> partition_specs{}; /// ID of the current partition spec that writers should use by default - int32_t default_spec_id; + int32_t default_spec_id{}; /// The highest assigned partition field ID across all partition specs for the table - int32_t last_partition_id; + int32_t last_partition_id{}; /// A string to string map of table properties - std::unordered_map properties; + std::unordered_map properties{}; /// ID of the current table snapshot - int64_t current_snapshot_id; + int64_t current_snapshot_id{}; /// A list of valid snapshots - std::vector> snapshots; + std::vector> snapshots{}; /// A list of timestamp and snapshot ID pairs that encodes changes to the current /// snapshot for the table - std::vector snapshot_log; + std::vector snapshot_log{}; /// A list of timestamp and metadata file location pairs that encodes changes to the /// previous metadata files for the table - std::vector metadata_log; + std::vector metadata_log{}; /// A list of sort orders - std::vector> sort_orders; + std::vector> sort_orders{}; /// Default sort order id of the table - int32_t default_sort_order_id; + int32_t default_sort_order_id{}; /// A map of snapshot references - std::unordered_map> refs; + std::unordered_map> refs{}; /// A list of table statistics - std::vector> statistics; + std::vector> statistics{}; /// A list of partition statistics - std::vector> partition_statistics; + std::vector> partition_statistics{}; /// A `long` higher than all assigned row IDs int64_t next_row_id; diff --git a/src/iceberg/table_requirements.cc b/src/iceberg/table_requirements.cc index aae874ecd..f46a7066a 100644 --- a/src/iceberg/table_requirements.cc +++ b/src/iceberg/table_requirements.cc @@ -34,19 +34,19 @@ Result>> TableUpdateContext::Build } Result>> TableRequirements::ForCreateTable( - const std::vector>& table_updates) { + [[maybe_unused]] const std::vector>& table_updates) { return NotImplemented("TableRequirements::ForCreateTable not implemented"); } Result>> TableRequirements::ForReplaceTable( - const TableMetadata& base, - const std::vector>& table_updates) { + [[maybe_unused]] const TableMetadata& base, + [[maybe_unused]] const std::vector>& table_updates) { return NotImplemented("TableRequirements::ForReplaceTable not implemented"); } Result>> TableRequirements::ForUpdateTable( - const TableMetadata& base, - const std::vector>& table_updates) { + [[maybe_unused]] const TableMetadata& base, + [[maybe_unused]] const std::vector>& table_updates) { return NotImplemented("TableRequirements::ForUpdateTable not implemented"); } diff --git a/src/iceberg/table_update.cc b/src/iceberg/table_update.cc index fcb7a58c2..216d761af 100644 --- a/src/iceberg/table_update.cc +++ b/src/iceberg/table_update.cc @@ -51,161 +51,178 @@ Status AssignUUID::GenerateRequirements(TableUpdateContext& context) const { // UpgradeFormatVersion -void UpgradeFormatVersion::ApplyTo(TableMetadataBuilder& builder) const { +void UpgradeFormatVersion::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status UpgradeFormatVersion::GenerateRequirements(TableUpdateContext& context) const { +Status UpgradeFormatVersion::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("UpgradeFormatVersion::GenerateRequirements not implemented"); } // AddSchema -void AddSchema::ApplyTo(TableMetadataBuilder& builder) const { +void AddSchema::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status AddSchema::GenerateRequirements(TableUpdateContext& context) const { +Status AddSchema::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("AddTableSchema::GenerateRequirements not implemented"); } // SetCurrentSchema -void SetCurrentSchema::ApplyTo(TableMetadataBuilder& builder) const { +void SetCurrentSchema::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status SetCurrentSchema::GenerateRequirements(TableUpdateContext& context) const { +Status SetCurrentSchema::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("SetCurrentTableSchema::GenerateRequirements not implemented"); } // AddPartitionSpec -void AddPartitionSpec::ApplyTo(TableMetadataBuilder& builder) const { +void AddPartitionSpec::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status AddPartitionSpec::GenerateRequirements(TableUpdateContext& context) const { +Status AddPartitionSpec::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("AddTablePartitionSpec::GenerateRequirements not implemented"); } // SetDefaultPartitionSpec -void SetDefaultPartitionSpec::ApplyTo(TableMetadataBuilder& builder) const { +void SetDefaultPartitionSpec::ApplyTo( + [[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status SetDefaultPartitionSpec::GenerateRequirements(TableUpdateContext& context) const { +Status SetDefaultPartitionSpec::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented( "SetDefaultTablePartitionSpec::GenerateRequirements not implemented"); } // RemovePartitionSpecs -void RemovePartitionSpecs::ApplyTo(TableMetadataBuilder& builder) const { +void RemovePartitionSpecs::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status RemovePartitionSpecs::GenerateRequirements(TableUpdateContext& context) const { +Status RemovePartitionSpecs::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented( "RemoveTablePartitionSpecs::GenerateRequirements not implemented"); } // RemoveSchemas -void RemoveSchemas::ApplyTo(TableMetadataBuilder& builder) const { +void RemoveSchemas::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status RemoveSchemas::GenerateRequirements(TableUpdateContext& context) const { +Status RemoveSchemas::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("RemoveTableSchemas::GenerateRequirements not implemented"); } // AddSortOrder -void AddSortOrder::ApplyTo(TableMetadataBuilder& builder) const { +void AddSortOrder::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status AddSortOrder::GenerateRequirements(TableUpdateContext& context) const { +Status AddSortOrder::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("AddTableSortOrder::GenerateRequirements not implemented"); } // SetDefaultSortOrder -void SetDefaultSortOrder::ApplyTo(TableMetadataBuilder& builder) const { +void SetDefaultSortOrder::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status SetDefaultSortOrder::GenerateRequirements(TableUpdateContext& context) const { +Status SetDefaultSortOrder::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("SetDefaultTableSortOrder::GenerateRequirements not implemented"); } // AddSnapshot -void AddSnapshot::ApplyTo(TableMetadataBuilder& builder) const { +void AddSnapshot::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status AddSnapshot::GenerateRequirements(TableUpdateContext& context) const { +Status AddSnapshot::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("AddTableSnapshot::GenerateRequirements not implemented"); } // RemoveSnapshots -void RemoveSnapshots::ApplyTo(TableMetadataBuilder& builder) const {} +void RemoveSnapshots::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const {} -Status RemoveSnapshots::GenerateRequirements(TableUpdateContext& context) const { +Status RemoveSnapshots::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("RemoveTableSnapshots::GenerateRequirements not implemented"); } // RemoveSnapshotRef -void RemoveSnapshotRef::ApplyTo(TableMetadataBuilder& builder) const { +void RemoveSnapshotRef::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status RemoveSnapshotRef::GenerateRequirements(TableUpdateContext& context) const { +Status RemoveSnapshotRef::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("RemoveTableSnapshotRef::GenerateRequirements not implemented"); } // SetSnapshotRef -void SetSnapshotRef::ApplyTo(TableMetadataBuilder& builder) const { +void SetSnapshotRef::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status SetSnapshotRef::GenerateRequirements(TableUpdateContext& context) const { +Status SetSnapshotRef::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("SetTableSnapshotRef::GenerateRequirements not implemented"); } // SetProperties -void SetProperties::ApplyTo(TableMetadataBuilder& builder) const { +void SetProperties::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status SetProperties::GenerateRequirements(TableUpdateContext& context) const { +Status SetProperties::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("SetTableProperties::GenerateRequirements not implemented"); } // RemoveProperties -void RemoveProperties::ApplyTo(TableMetadataBuilder& builder) const { +void RemoveProperties::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status RemoveProperties::GenerateRequirements(TableUpdateContext& context) const { +Status RemoveProperties::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("RemoveTableProperties::GenerateRequirements not implemented"); } // SetLocation -void SetLocation::ApplyTo(TableMetadataBuilder& builder) const { +void SetLocation::ApplyTo([[maybe_unused]] TableMetadataBuilder& builder) const { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -Status SetLocation::GenerateRequirements(TableUpdateContext& context) const { +Status SetLocation::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { return NotImplemented("SetTableLocation::GenerateRequirements not implemented"); } diff --git a/src/iceberg/test/schema_test.cc b/src/iceberg/test/schema_test.cc index 89a8d54b5..525decb1d 100644 --- a/src/iceberg/test/schema_test.cc +++ b/src/iceberg/test/schema_test.cc @@ -603,12 +603,12 @@ static std::unique_ptr ComplexMapSchema() { } // namespace struct SelectTestParam { - std::string test_name; - std::function()> create_schema; - std::vector select_fields; - std::function()> expected_schema; - bool should_succeed; - std::string expected_error_message; + std::string test_name{}; + std::function()> create_schema{}; + std::vector select_fields{}; + std::function()> expected_schema{}; + bool should_succeed{}; + std::string expected_error_message{}; bool case_sensitive = true; }; @@ -744,12 +744,12 @@ INSTANTIATE_TEST_SUITE_P( .should_succeed = true})); struct ProjectTestParam { - std::string test_name; - std::function()> create_schema; - std::unordered_set selected_ids; - std::function()> expected_schema; - bool should_succeed; - std::string expected_error_message; + std::string test_name{}; + std::function()> create_schema{}; + std::unordered_set selected_ids{}; + std::function()> expected_schema{}; + bool should_succeed{}; + std::string expected_error_message{}; }; class ProjectParamTest : public ::testing::TestWithParam {}; diff --git a/src/iceberg/test/schema_util_test.cc b/src/iceberg/test/schema_util_test.cc index fe6579ab3..a9c7a2c40 100644 --- a/src/iceberg/test/schema_util_test.cc +++ b/src/iceberg/test/schema_util_test.cc @@ -82,14 +82,14 @@ std::shared_ptr CreateNestedStruct() { }); } -std::shared_ptr CreateListOfList() { +[[maybe_unused]] std::shared_ptr CreateListOfList() { return std::make_shared(SchemaField::MakeRequired( /*field_id=*/401, "element", std::make_shared(SchemaField::MakeOptional( /*field_id=*/402, "element", iceberg::float64())))); } -std::shared_ptr CreateMapOfList() { +[[maybe_unused]] std::shared_ptr CreateMapOfList() { return std::make_shared( SchemaField::MakeRequired(/*field_id=*/501, "key", iceberg::string()), SchemaField::MakeRequired( diff --git a/src/iceberg/test/transform_test.cc b/src/iceberg/test/transform_test.cc index 529297b27..f7fd12c61 100644 --- a/src/iceberg/test/transform_test.cc +++ b/src/iceberg/test/transform_test.cc @@ -195,7 +195,7 @@ TEST(TransformResultTypeTest, NegativeCases) { struct TransformParam { std::string str; // The integer parameter associated with the transform. - int32_t param; + int32_t param = 0; std::shared_ptr source_type; Literal source; Literal expected; diff --git a/src/iceberg/util/conversions.cc b/src/iceberg/util/conversions.cc index 0cc7c55d8..87621a067 100644 --- a/src/iceberg/util/conversions.cc +++ b/src/iceberg/util/conversions.cc @@ -200,7 +200,7 @@ Result Conversions::FromBytes(const PrimitiveType& type, return Literal::Value{std::vector(data.begin(), data.end())}; case TypeId::kFixed: { const auto& fixed_type = static_cast(type); - if (data.size() != fixed_type.length()) { + if (static_cast(data.size()) != fixed_type.length()) { return InvalidArgument("Invalid data size for Fixed literal, got size: {}", data.size()); } diff --git a/src/iceberg/util/truncate_util.cc b/src/iceberg/util/truncate_util.cc index 9d0c6e7ea..300762187 100644 --- a/src/iceberg/util/truncate_util.cc +++ b/src/iceberg/util/truncate_util.cc @@ -66,7 +66,7 @@ Literal TruncateLiteralImpl(const Literal& literal, int32_t wid // In contrast to strings, binary values do not have an assumed encoding and are // truncated to `width` bytes. const auto& data = std::get>(literal.value()); - if (data.size() <= width) { + if (static_cast(data.size()) <= width) { return literal; } return Literal::Binary(std::vector(data.begin(), data.begin() + width));