diff --git a/src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergFieldParseHelpers.cpp b/src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergFieldParseHelpers.cpp index e062057a99c6a..bfd0c91d073cc 100644 --- a/src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergFieldParseHelpers.cpp +++ b/src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergFieldParseHelpers.cpp @@ -286,6 +286,12 @@ deserializeFieldFromBinaryRepr(const std::string & str, DataTypePtr expected_typ if (non_nullable_type->getTypeId() == TypeIndex::Variant) return std::nullopt; + /// `insertData` of a fixed-size column ignores the length and reads the width of the type, so a + /// shorter bound would read past the buffer. Iceberg keeps the bound as written, which for a + /// promoted column (`int` -> `long`) is narrower than the column is now. + if (non_nullable_type->haveMaximumSizeOfValue() && str.size() < non_nullable_type->getSizeOfValueInMemory()) + return std::nullopt; + /// For all other types except decimal binary representation /// matches our internal representation column->insertData(str.data(), str.length());