This cast could fail if value is neither Serializable nor an IndexedRecord. It would be better to test explicitly and fail with a better message.

Actually, shouldn't we also support Avro reflect here?