Partner holds between 7 and 9 points, including the Q of hearts and the QJ of clubs. The only unclear item is whether partner holds the A of hearts as well. If partner started with AQx of hearts, simply leading another heart to partner will set the contract. Otherwise, leading a spade makes sense.
The key inference is that partner did not continue hearts at trick 2. Holding AQ alone or Qxx(x), East would have to continue hearts to unblock/clear the suit before establishing clubs. In doing so, however, East would have won the first trick with the A! By the winning the Q, East learns whether the heart suit runs or not, clarifying the situation for West when he switches suits.
West should conclude that East has the A of hearts based on this, and comfortably continue the 2 of hearts.