|
22 | 22 | #include <IO/ReadBufferFromString.h> |
23 | 23 | #include <IO/ReadHelpers.h> |
24 | 24 |
|
| 25 | +#include <Common/logger_useful.h> |
| 26 | + |
| 27 | + |
25 | 28 | namespace DB::ErrorCodes |
26 | 29 | { |
27 | 30 | extern const int ICEBERG_SPECIFICATION_VIOLATION; |
@@ -143,7 +146,7 @@ ManifestFileContent::ManifestFileContent( |
143 | 146 | const String & manifest_file_name, |
144 | 147 | Int32 format_version_, |
145 | 148 | const String & common_path, |
146 | | - const IcebergSchemaProcessor & schema_processor, |
| 149 | + IcebergSchemaProcessor & schema_processor, |
147 | 150 | Int64 inherited_sequence_number, |
148 | 151 | Int64 inherited_snapshot_id, |
149 | 152 | const String & table_location, |
@@ -196,6 +199,8 @@ ManifestFileContent::ManifestFileContent( |
196 | 199 | const Poco::JSON::Object::Ptr & schema_object = json.extract<Poco::JSON::Object::Ptr>(); |
197 | 200 | Int32 manifest_schema_id = schema_object->getValue<int>(f_schema_id); |
198 | 201 |
|
| 202 | + schema_processor.addIcebergTableSchema(schema_object); |
| 203 | + |
199 | 204 | for (size_t i = 0; i != partition_specification->size(); ++i) |
200 | 205 | { |
201 | 206 | auto partition_specification_field = partition_specification->getObject(static_cast<UInt32>(i)); |
@@ -262,13 +267,22 @@ ManifestFileContent::ManifestFileContent( |
262 | 267 | const auto schema_id_opt = schema_processor.tryGetSchemaIdForSnapshot(snapshot_id); |
263 | 268 | if (!schema_id_opt.has_value()) |
264 | 269 | { |
265 | | - throw Exception( |
266 | | - ErrorCodes::ICEBERG_SPECIFICATION_VIOLATION, |
267 | | - "Cannot read Iceberg table: manifest file '{}' has entry with snapshot_id '{}' for which write file schema is unknown", |
268 | | - manifest_file_name, |
269 | | - snapshot_id); |
| 270 | + /// Error logged but not thrown to avoid breaking whole query because of backward compatibility reasons. |
| 271 | + /// That's actually an error because it can lead to incorrect query results, so we are creating an exception to put it to system.error_log. |
| 272 | + try |
| 273 | + { |
| 274 | + throw Exception( |
| 275 | + ErrorCodes::ICEBERG_SPECIFICATION_VIOLATION, |
| 276 | + "Cannot read Iceberg table: manifest file '{}' has entry with snapshot_id '{}' for which write file schema is unknown", |
| 277 | + manifest_file_name, |
| 278 | + snapshot_id); |
| 279 | + } |
| 280 | + catch (const Exception &) |
| 281 | + { |
| 282 | + tryLogCurrentException("ICEBERG_SPECIFICATION_VIOLATION", "", LogsLevel::error); |
| 283 | + } |
270 | 284 | } |
271 | | - const auto schema_id = schema_id_opt.value(); |
| 285 | + const auto schema_id = schema_id_opt.has_value() ? schema_id_opt.value() : manifest_schema_id; |
272 | 286 |
|
273 | 287 | const auto file_path_key |
274 | 288 | = manifest_file_deserializer.getValueFromRowByName(i, c_data_file_file_path, TypeIndex::String).safeGet<String>(); |
|
0 commit comments