John got to the quarry nice and early, and was warmly greeted by his friend the truck driver, who had expected him.
This bit of information about the friend ("who had expected him") is not the kind of information that defines friends. It is purely supplementary. So, whether John has only one friend or it's a friend who has already been defined or is defined here by his occupation, you will need the comma:
John got to the quarry nice and early, and was warmly greeted by his friend, who had expected him.
John got to the quarry nice and early, and was warmly greeted by his friend Martin, who had expected him.
John got to the quarry nice and early, and was warmly greeted by his friend the truck driver, who had expected him.