Oscar Piastri edged out team-mate Lando Norris to pole as McLaren celebrated their first front row lockout at the Spanish Grand Prix in 27 years.