Partial wave decomposition on the lattice and its applications to the HAL QCD method