Valtteri Bottas beat Mercedes team-mate Lewis Hamilton to the first pole position of F1's delayed season despite a spin on his last lap.