What is the attacker for Spiritual Weapon the caster or the weapon?


This question was prompted by this question about the relation to the rogue’s uncanny dodge feature and being able to see the attacker when spiritual weapon is used.

When a creature is subject to the magic melee attack of spiritual weapon what is considered to be the attacker?

  • Is the caster considered the attacker?
  • Is the spiritual weapon itself considered the attacker?
  • Are both?