Diamondbacks edge Giants 3-2 in 10 innings