public static Records recordsOrFail(FetchResponseData.PartitionData partition) {
        if (partition.records() == null) return MemoryRecords.EMPTY;
        if (partition.records() instanceof Records) return (Records) partition.records();
        throw new ClassCastException("The record type is " + partition.records().getClass().getSimpleName() + ", which is not a subtype of " +
            Records.class.getSimpleName() + ". This method is only safe to call if the `FetchResponse` was deserialized from bytes.");
    }
Returns `partition.records` as `Records` (instead of `BaseRecords`). If `records` is `null`, returns `MemoryRecords.EMPTY`.

If this response was deserialized after a fetch, this method should never fail. An example where this would
fail is a down-converted response (e.g. LazyDownConversionRecords) on the broker (before it's serialized and
sent on the wire).

@param partition partition data
@return Records or empty record if the records in PartitionData is null.
clients/src/main/java/org/apache/kafka/common/requests/FetchResponse.java