From 05d8584966b05ed2196fc1ffb3bf0ecbdf9ac910 Mon Sep 17 00:00:00 2001 From: divanik Date: Tue, 10 Dec 2024 10:34:36 +0000 Subject: [PATCH 1/3] Fix chassert --- .../ObjectStorage/DataLakes/IcebergMetadata.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp b/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp index 980d2f479cb..5352fc641fa 100644 --- a/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp +++ b/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp @@ -128,6 +128,14 @@ bool operator!=(const Poco::JSON::Object & first, const Poco::JSON::Object & sec { return !(first == second); } + +bool schemasAreIdentical(const Poco::JSON::Object & first, const Poco::JSON::Object & second) +{ + static String fields_key = "fields"; + if (!first.has(fields_key) || !second.has(fields_key)) + return false; + return first.getObject(fields_key) == second.getObject(fields_key); +} } @@ -481,7 +489,7 @@ void IcebergSchemaProcessor::addIcebergTableSchema(Poco::JSON::Object::Ptr schem if (iceberg_table_schemas_by_ids.contains(schema_id)) { chassert(clickhouse_table_schemas_by_ids.contains(schema_id)); - chassert(*iceberg_table_schemas_by_ids.at(schema_id) == *schema_ptr); + chassert(schemasAreIdentical(*iceberg_table_schemas_by_ids.at(schema_id), *schema_ptr)); } else { From 57d446ebfdb7c0aaed5c30292dcb2467a965d8d0 Mon Sep 17 00:00:00 2001 From: divanik Date: Tue, 10 Dec 2024 10:44:22 +0000 Subject: [PATCH 2/3] Fix bug --- src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp b/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp index 5352fc641fa..8b83f6434db 100644 --- a/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp +++ b/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp @@ -134,7 +134,7 @@ bool schemasAreIdentical(const Poco::JSON::Object & first, const Poco::JSON::Obj static String fields_key = "fields"; if (!first.has(fields_key) || !second.has(fields_key)) return false; - return first.getObject(fields_key) == second.getObject(fields_key); + return (*first.getObject(fields_key)) == (*second.getObject(fields_key)); } } From 72cc0645472136effec57e22e26344cefc0e0c0d Mon Sep 17 00:00:00 2001 From: divanik Date: Tue, 10 Dec 2024 11:07:48 +0000 Subject: [PATCH 3/3] Fix bug --- .../ObjectStorage/DataLakes/IcebergMetadata.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp b/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp index 8b83f6434db..9cf4f64cdb3 100644 --- a/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp +++ b/src/Storages/ObjectStorage/DataLakes/IcebergMetadata.cpp @@ -107,7 +107,8 @@ std::pair parseDecimal(const String & type_name) return {precision, scale}; } -bool operator==(const Poco::JSON::Object & first, const Poco::JSON::Object & second) +template +bool equals(const T & first, const T & second) { std::stringstream first_string_stream; // STYLE_CHECK_ALLOW_STD_STRING_STREAM std::stringstream second_string_stream; // STYLE_CHECK_ALLOW_STD_STRING_STREAM @@ -124,17 +125,23 @@ bool operator==(const Poco::JSON::Object & first, const Poco::JSON::Object & sec return first_string_stream.str() == second_string_stream.str(); } -bool operator!=(const Poco::JSON::Object & first, const Poco::JSON::Object & second) + +bool operator==(const Poco::JSON::Object & first, const Poco::JSON::Object & second) { - return !(first == second); + return equals(first, second); +} + +bool operator==(const Poco::JSON::Array & first, const Poco::JSON::Array & second) +{ + return equals(first, second); } bool schemasAreIdentical(const Poco::JSON::Object & first, const Poco::JSON::Object & second) { static String fields_key = "fields"; - if (!first.has(fields_key) || !second.has(fields_key)) + if (!first.isArray(fields_key) || !second.isArray(fields_key)) return false; - return (*first.getObject(fields_key)) == (*second.getObject(fields_key)); + return *(first.getArray(fields_key)) == *(second.getArray(fields_key)); } }